Skip to content

Instantly share code, notes, and snippets.

@DV8FromTheWorld
Created June 26, 2014 22:17
Show Gist options
  • Save DV8FromTheWorld/caea9e3a4711e9bedf98 to your computer and use it in GitHub Desktop.
Save DV8FromTheWorld/caea9e3a4711e9bedf98 to your computer and use it in GitHub Desktop.
private static String toBase64(BufferedImage image, String format)
{
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
try
{
ImageIO.write(image, format, byteArray);
return URLEncoder.encode(DatatypeConverter.printBase64Binary(byteArray.toByteArray()), "UTF-8");
}
catch (UnsupportedEncodingException e)
{
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment