(String str_img,String words)
| 53 | } |
| 54 | |
| 55 | public static boolean isImage(String str_img,String words) throws IOException { |
| 56 | // System.out.println(str_img); |
| 57 | String pattern = "(" + words + ".*?)[,&}/+=\\w]+"; |
| 58 | Pattern r = Pattern.compile(pattern); |
| 59 | Matcher m = r.matcher(str_img); |
| 60 | if (m.find( )) { |
| 61 | str_img = m.group(0).replace("\"","").replace("&","").replace("Base64:","").replace("base64:","") ; |
| 62 | } |
| 63 | if (!str_img.contains("data:image")){ |
| 64 | str_img = "data:image/jpeg;base64," + str_img; |
| 65 | } |
| 66 | |
| 67 | byte[] img = DatatypeConverter.parseBase64Binary(str_img.substring(str_img.indexOf(",") + 1)); |
| 68 | boolean isImg = false; |
| 69 | InputStream buffin = new ByteArrayInputStream(img); |
| 70 | BufferedImage image = ImageIO.read(buffin); |
| 71 | if(image == null){ |
| 72 | isImg = false; |
| 73 | }else { |
| 74 | isImg = true; |
| 75 | } |
| 76 | // System.out.println(isImg); |
| 77 | return isImg; |
| 78 | } |
| 79 | |
| 80 | public static boolean isImage(String str_img) throws IOException { |
| 81 | // System.out.println(str_img); |
no outgoing calls
no test coverage detected