-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadFile.java
More file actions
32 lines (29 loc) · 1.12 KB
/
ReadFile.java
File metadata and controls
32 lines (29 loc) · 1.12 KB
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
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReadFile {
public static String readFile(String url, boolean withLineWrap){
String result = "";
try {
FileReader fr = new FileReader(url);
BufferedReader br = new BufferedReader(fr);
String temp = null;
if ( withLineWrap ) {
while ( ( temp=br.readLine() ) !=null ){
result += (temp+"\n");
}
}
else {
while ( ( temp=br.readLine() ) !=null ){
result += temp;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
}