File操作

long startTime = System.nanoTime();
File file = new File("D:"+File.separator+"1.jpg");
File file2 = new File("D:"+File.separator+"2.jpg");
InputStream input = new FileInputStream(file);
OutputStream out = new FileOutputStream(file2);
BufferedInputStream bufInput = new BufferedInputStream(input);
BufferedOutputStream bufOut = new BufferedOutputStream(out);
byte[] b = new byte[(int)file.length()];
while(!(-1==bufInput.read(b))){
bufOut.write(b);
}
input.close();
out.close();
out.flush();
System.out.println(System.nanoTime());

你可能感兴趣的:(File)