(String str_img)
| 109 | } |
| 110 | |
| 111 | public static byte[] dataimgToimg(String str_img) throws IOException { |
| 112 | String pattern = "(data:image.*?)[\"|&]|(data%2Aimage.*?)[\"|&]"; |
| 113 | str_img = str_img.replace("\\r\\n",""); |
| 114 | str_img = str_img.replace("\\n","").replace("\\",""); |
| 115 | str_img = str_img.replace("_","/").replace("-","+"); |
| 116 | // stdout.println(str_img); |
| 117 | str_img = URLDecoder.decode(str_img,"utf-8"); |
| 118 | Pattern r = Pattern.compile(pattern); |
| 119 | Matcher m = r.matcher(str_img); |
| 120 | if (m.find( )) { |
| 121 | str_img = m.group(0).replace("\"","").replace("&","").replace("Base64:","").replace("base64:","").replace(".","") ; |
| 122 | } |
| 123 | if (!str_img.contains("data:image")){ |
| 124 | str_img = "data:image/jpeg;base64," + str_img; |
| 125 | } |
| 126 | str_img = str_img.replace(" ","+"); |
| 127 | byte[] img = DatatypeConverter.parseBase64Binary(str_img.substring(str_img.indexOf(",") + 1)); |
| 128 | // InputStream buffin = new ByteArrayInputStream(img); |
| 129 | return img; |
| 130 | } |
| 131 | |
| 132 | public static String extractToken(String str_img,String token) throws IOException { |
| 133 | String pattern = token ; |
no outgoing calls
no test coverage detected