Skip to content

Instantly share code, notes, and snippets.

@DV8FromTheWorld
Created June 26, 2014 22:56
Show Gist options
  • Save DV8FromTheWorld/875638f96cb0eba4959a to your computer and use it in GitHub Desktop.
Save DV8FromTheWorld/875638f96cb0eba4959a to your computer and use it in GitHub Desktop.
private static String toBase64(File file)
{
try
{
byte[] b = new byte[(int) file.length()];
FileInputStream fs = new FileInputStream(file);
fs.read(b);
fs.close();
return URLEncoder.encode(DatatypeConverter.printBase64Binary(b), "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