-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharge.java
31 lines (29 loc) · 1.01 KB
/
charge.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.java.test;
import java.io.*;
import java.util.Scanner;
/**
* description: 文件拷贝(速度快)
* author: 朱勇
* time: 2020/7/1 8:47
*/
public class charge {
public static void main(String[] args) throws IOException {
System.out.println("请输入需要拷贝的文件路径:");
Scanner in=new Scanner(System.in);
String str1=in.nextLine();
System.out.println("请输入目标路径:");
String str2=in.nextLine();
long starttime=System.currentTimeMillis();
BufferedInputStream bi=new BufferedInputStream(new FileInputStream(str1));
BufferedOutputStream bo=new BufferedOutputStream(new FileOutputStream(str2));
byte[] car=new byte[1024];
int data;
for(;(data=bi.read(car))!=-1;){
bo.write(car,0,data);
}
bi.close();
bo.close();
long endtime=System.currentTimeMillis();
System.out.println("共消耗"+(endtime-starttime)+"ms");
}
}