标题: 文件的拷贝 [打印本页] 作者: 943480861 时间: 2016-4-16 23:12 标题: 文件的拷贝 package Buffer1;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Buffer_Demo {
@SuppressWarnings("resource")
public static void main(String[] args) throws IOException {
long st = System.currentTimeMillis();
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("IMG_2162.PNG"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("IMG_COPY.PNG"));
byte[]by=new byte[1024];
int len=0;
while ((len=bis.read(by))!=-1) {
bos.write(by,0,len);
//System.out.println(by);
}
bis.close();
bos.close();
long cur = System.currentTimeMillis();
System.out.println("总时间为"+(cur-st));