1
2private static void copyFileUsingStream(File source, File dest) throws IOException {
3 InputStream is = null;
4 OutputStream os = null;
5 try {
6 is = new FileInputStream(source);
7 os = new FileOutputStream(dest);
8 byte[] buffer = new byte[1024];
9 int length;
10 while ((length = is.read(buffer)) > 0) {
11 os.write(buffer, 0, length);
12 }
13 } finally {
14 is.close();
15 os.close();
16 }
17}
18