-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathParser.java
More file actions
28 lines (24 loc) · 788 Bytes
/
Parser.java
File metadata and controls
28 lines (24 loc) · 788 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
package track.lessons.lesson2;
import java.io.BufferedReader;
import java.io.FileReader;
public class Parser {
Document parse(String data) {
String[] tokens = data.split("[ ]");
if (tokens == null) {
return null;
}
return new Document(tokens);
}
public static void main(String[] args) throws Exception {
String path = "path/to/file";
BufferedReader reader = new BufferedReader(new FileReader(path));
StringBuilder builder = new StringBuilder();
Parser pars = new Parser();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
String res = builder.toString();
Document doc = pars.parse(res);
}
}