-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAAAreader.java~
More file actions
47 lines (43 loc) · 1.94 KB
/
AAAreader.java~
File metadata and controls
47 lines (43 loc) · 1.94 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class AAAreader {
public static void main(String[] args) {
try {
File path = new File("/Users/noellependergraft/Documents/Research/AAA/html");
File[] files = path.listFiles();
for (File file:files) {
Scanner scan = new Scanner(file);
String line = scan.nextLine();
String toPrint = "";
while (scan.hasNextLine()) {
line = scan.nextLine().trim();
if (line.startsWith("\"datePublished\": \"")) {
line = line.replace("\"datePublished\": \"","");
//System.out.println(line.substring(0,line.lastIndexOf("\"")));
toPrint += line.substring(0,line.lastIndexOf("\"")) + "\t";
} else if (line.startsWith("\"reviewBody\": \"")) {
line = line.replace("\"reviewBody\": \"","");
//System.out.println(line.substring(0,line.lastIndexOf("\"")));
toPrint += line.substring(0,line.lastIndexOf("\"")) + "\t";
} else if (line.startsWith("\"author\":")) {
line = scan.nextLine().trim();
line = line.replace("\"@type\": \"","");
//System.out.println(line.substring(0,line.lastIndexOf("\"")));
toPrint += line.substring(0,line.lastIndexOf("\"")) + "\t";
line = scan.nextLine().trim();
line = line.replace("\"name\":\"","");
//System.out.println(line.substring(0,line.lastIndexOf("\"")));
toPrint += line.substring(0,line.lastIndexOf("\"")) + "\t";
} else if (line.startsWith("\"ratingValue\": \"")) {
line = line.replace("\"ratingValue\": \"","");
//System.out.println(line.substring(0,line.lastIndexOf("\"")));
toPrint += line.substring(0,line.lastIndexOf("\"")) + "\t";
}
System.out.println(toPrint);
}
}
} catch (FileNotFoundException e) {
}
}
}