-
Notifications
You must be signed in to change notification settings - Fork 0
/
erty.java
47 lines (45 loc) · 1.09 KB
/
erty.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.*;
public class erty {
public static void main(String[]args){
File src= null;
if (args != null) {
if (args[0] != null) {
src = new File(args[0]);
}
}
File des = null;
if (args != null && args[1] != null) {
des = new File(args[1]);
}
try{
copy(src,des);
if (des != null) {
System.out.println(des.length()+"字节已被复制,文件复");
}
}catch(IOException e){
System.out.println("文件复制失败!");
}
}
public static void copy(File src,File des)throws IOException {
BufferedReader br= null;
if (src != null) {
br = new BufferedReader(new FileReader(src));
}
BufferedWriter bw= null;
if (des != null) {
bw = new BufferedWriter(new FileWriter(des));
}
String str;
if (br != null) {
while((str=br.readLine())!=null){
assert bw != null;
bw.write(str);
bw.newLine();
}
}
assert br != null;
br.close( );
assert bw != null;
bw.close();
}
}