Here you can find the source of copyFileUsingFileStreams(final File source, final File dest)
private static void copyFileUsingFileStreams(final File source, final File dest) throws IOException
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { private static void copyFileUsingFileStreams(final File source, final File dest) throws IOException { InputStream input = null; OutputStream output = null; try {/* w ww . j a v a 2s. c o m*/ FileInputStream _fileInputStream = new FileInputStream(source); input = _fileInputStream; FileOutputStream _fileOutputStream = new FileOutputStream(dest); output = _fileOutputStream; byte[] buf = new byte[1024]; int bytesRead = 0; while (((bytesRead = input.read(buf)) > 0)) { output.write(buf, 0, bytesRead); } } finally { input.close(); output.close(); } } }