import java.io.*; public class X { public static void copy(String from, String to)throws IOException{ InputStream inFile = null; OutputStream outFile = null; try { inFile = new FileInputStream(from); outFile = new FileOutputStream(to); int length = inFile.available(); byte[] bytes = new byte[length]; inFile.read(bytes); outFile.write(bytes); } finally { inFile.close(); outFile.close(); } } public static void copyBuf(String from, String to)throws IOException{ InputStream in = null; OutputStream out = null; InputStream inFile = null; OutputStream outFile = null; try { inFile = new FileInputStream(from); in = new BufferedInputStream(inFile); outFile = new FileOutputStream(to); out = new BufferedOutputStream(outFile); int length = in.available(); byte[] bytes = new byte[length]; in.read(bytes); out.write(bytes); } finally { in.close(); out.close(); } } public static void main(String[] args) { try { long l = System.currentTimeMillis(); copy(args[0], args[1]); System.out.println("Time = "+ (System.currentTimeMillis()-l)); l = System.currentTimeMillis(); copyBuf(args[0], args[1]); System.out.println("Buf Time = "+ (System.currentTimeMillis()-l)); } catch (IOException e) { e.printStackTrace(); } } }