-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileCopy.java
More file actions
27 lines (26 loc) · 800 Bytes
/
FileCopy.java
File metadata and controls
27 lines (26 loc) · 800 Bytes
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
import java.io.*;
public class FileCopy {
public static void main(String[] args) {
FileReader fr = null;
FileWriter fw = null;
try {
fr = new FileReader("test1.txt");
fw = new FileWriter("test2.txt");
int ch;
while((ch = fr.read()) != -1)
fw.write(ch);
System.out.println("파일 복사 완료");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fr != null)
try {
fr.close();
} catch (IOException e) { e.printStackTrace(); }
if (fw != null)
try {
fw.close();
} catch (IOException e) { e.printStackTrace(); }
}
}
}