test
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 { InputStream inFile = new FileInputStream (from); in = new BufferedInputStream (inFile); OutputStream out = new FileOutputStream (to); out = new BufferedOutputstream (outFile); 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(); } } } }
Most popular snippets