-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilehandling2.java
More file actions
31 lines (30 loc) · 819 Bytes
/
filehandling2.java
File metadata and controls
31 lines (30 loc) · 819 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
28
29
30
31
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class filehandling2 {
public static void main(String[] args) {
//Using FILEREADER AND FILEWRITER
FileReader in=null;
FileWriter out=null;
try{
in=new FileReader("input.txt");
out=new FileWriter("output.txt");
int i;
while ((i=in.read())!=-1) {
out.write(i);
}
}catch(IOException e){
System.out.println(e);
}finally{
try{
if (in!=null) {
in.close();
}if (out!=null) {
out.close();
}
}catch(IOException e){
System.out.print(e);
}
}
}
}