Cipher des = Cipher.getInstance("DES/CBC/PKCS#5"); CipherOutputStream out = new CipherOutputStream(fileOut, des); int read = 0; while((read = in.read()) != -1) { out.write(read); } out.flush();