Created
June 26, 2014 22:56
-
-
Save DV8FromTheWorld/875638f96cb0eba4959a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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