-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilehandling.java
More file actions
33 lines (29 loc) · 885 Bytes
/
Copy pathFilehandling.java
File metadata and controls
33 lines (29 loc) · 885 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
32
33
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Filehandling {
public static void main(String[] args) {
try{
BufferedWriter bw = new BufferedWriter(new FileWriter("R:\\PF\\Learning java\\Input.txt"));
for(int i =1;i<=10;i++){
bw.write(i + "\n" );
}
bw.close();
}
catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader br = new BufferedReader(new FileReader("R:\\PF\\Learning java\\Input.txt"));
String line;
while((line = br.readLine()) !=null){
System.out.println(line);
}
}
catch (IOException e) {
e.printStackTrace();
}
}
}