import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Test { public static void main (String args[]) throws IOException { String from = "D:/src/test.jpg"; String to = "D:/dest/test.jpg"; copy(from, to); } public static void copy (String from, String to) throws IOException { InputStream in = null; OutputStream out = null; System.out.println(System.currentTimeMillis()) { try { in = new FileInputStream(from); out = new FileOutputStream(to); while(true) { int data = in.read(); if (data == -1) { break; } out.write(data) } System.out.println(System.currentTimeMillis()) } finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } }