Created
December 18, 2010 21:56
-
-
Save eggie5/746911 to your computer and use it in GitHub Desktop.
encode arbitrary file to base64 string (java)
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
String s= new String(); | |
int BUFFER_SIZE = 4096; | |
byte[] buffer = new byte[BUFFER_SIZE]; | |
InputStream input = new FileInputStream(args[0]); | |
OutputStream output = new Base64OutputStream(new FileOutputStream(args[1])); | |
int n = input.read(buffer, 0, BUFFER_SIZE); | |
while (n >= 0) { | |
output.write(buffer, 0, n); | |
n = input.read(buffer, 0, BUFFER_SIZE); | |
} | |
input.close(); | |
output.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment