public class CopyFileByStream {
public static void main(String[] args) {
try {
FileInputStream fileInputStream = new FileInputStream("learn.txt");
FileOutputStream fileOutputStream = new FileOutputStream("learn22.txt",true);
byte b [] = new byte[1024];
int count = 0;
long before = System.currentTimeMillis();
while(fileInputStream.read(b)!= -1){
fileOutputStream.write(b);
count++;
}
//输入当前计算次数
System.out.println(count);
System.out.println(System.currentTimeMillis()-before);
fileInputStream.close();
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
网友评论