-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.java
More file actions
34 lines (30 loc) · 933 Bytes
/
Copy pathUtil.java
File metadata and controls
34 lines (30 loc) · 933 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
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URISyntaxException;
public class Util {
public static String readFile(String name) throws IOException, URISyntaxException {
File file = new File(
Thread.currentThread().getContextClassLoader().getResource(name).toURI()
);
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append("\n");
line = br.readLine();
}
return sb.toString();
}
}
public static class Pair<A, B> {
public A a;
public B b;
public Pair(A a, B b) {
this.a = a;
this.b = b;
}
}
}