-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathReadFile.java
More file actions
35 lines (33 loc) · 975 Bytes
/
Copy pathReadFile.java
File metadata and controls
35 lines (33 loc) · 975 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
34
35
package fileoperation;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class ReadFile {
public static void main(String[] args) throws IOException{
FileReader fr = null;
BufferedReader br = null;
String path = "/Users/peoplentech/develop/SeleniumJuly2018/class-notes/space.txt";
try{
fr = new FileReader(path);
}catch(Exception ex){
System.out.print("File is not found, plz check the path");
}
try{
br = new BufferedReader(fr);
String data="";
while((data = br.readLine()) != null){
System.out.println(data);
}
}catch(Exception ex){
System.out.print("File is not readable");
}
finally{
if(fr != null){
fr.close();
}
if(br != null){
br.close();
}
}
}
}