Skip to content

Instantly share code, notes, and snippets.

@Jaymo
Created February 29, 2016 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jaymo/3ba1a52d6c4b815f81ee to your computer and use it in GitHub Desktop.
Save Jaymo/3ba1a52d6c4b815f81ee to your computer and use it in GitHub Desktop.
private final static int DEFAULT_READ_WRITE_BLOCK_BUFFER_SIZE = 1024;
public static void applyCipher(String inFile, String outFile, Cipher cipher) throws Exception {
CipherInputStream in = new CipherInputStream(new FileInputStream(inFile), cipher);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile));
byte[] buffer = new byte[DEFAULT_READ_WRITE_BLOCK_BUFFER_SIZE];
int count = 0;
while ((count = in.read(buffer)) >= 0) {
out.write(buffer, 0, count);
}
in.close();
out.flush();
out.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment