-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadTweets.java
47 lines (33 loc) · 1.46 KB
/
ReadTweets.java
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.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
public class ReadTweets {
public static void listFilesForFolder(final File folder,ArrayList<Review> Data) throws IOException {
for (final File fileEntry : folder.listFiles()) {
if (fileEntry.isFile()) {
String fileName = fileEntry.getName();
BufferedReader bufferReader = new BufferedReader(new FileReader(folder.getAbsolutePath()+ "\\" +fileName));
try {
StringBuilder stringBuilder = new StringBuilder();
String line = bufferReader.readLine();
while (line != null) {
stringBuilder.append(line);
stringBuilder.append("\n");
line = bufferReader.readLine();
}
Review review = new Review(Integer.parseInt(fileName.substring(0,fileName.indexOf('_'))),stringBuilder.toString().toLowerCase(),Integer.parseInt(fileName.substring(fileName.length()-5,fileName.length()-4)));
printReview(review.review);
Data.add(review);
} finally {
bufferReader.close();
}
}
}
}
private static void printReview(String review) {
// TODO Auto-generated method stub
System.out.println(review);
}
}