Java File copy using BufferedInputStream and BufferedOutputStream
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static void main(String[] args) throws Exception { String fromFileName = "from.txt"; String toFileName = "to.txt"; BufferedInputStream in = new BufferedInputStream(new FileInputStream(fromFileName)); BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(toFileName)); byte[] buff = new byte[32 * 1024]; int len;/*from w w w . j a v a2 s .co m*/ while ((len = in.read(buff)) > 0) out.write(buff, 0, len); in.close(); out.close(); System.out.println("done"); } }