List of utility methods to do BufferedImage to String
String | encodeToString(BufferedImage image, String type) Encode image to string ByteArrayOutputStream bos = new ByteArrayOutputStream(); ImageIO.write(image, type, bos); byte[] imageBytes = bos.toByteArray(); BASE64Encoder encoder = new BASE64Encoder(); String imageString = encoder.encode(imageBytes); bos.close(); return imageString; |
String | encodeToString(BufferedImage image, String type) Encode to string. String imageString = null; ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { ImageIO.write(image, type, bos); byte[] imageBytes = bos.toByteArray(); imageString = DatatypeConverter.printBase64Binary(imageBytes); bos.close(); } catch (IOException e) { ... |
String | encodeToString(BufferedImage image, String type) encode To String String imageString = null; ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { ImageIO.write(image, type, bos); byte[] imageBytes = bos.toByteArray(); BASE64Encoder encoder = new BASE64Encoder(); imageString = encoder.encode(imageBytes); bos.close(); ... |