-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParser.java
More file actions
46 lines (44 loc) · 1.2 KB
/
Copy pathParser.java
File metadata and controls
46 lines (44 loc) · 1.2 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
package twitter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Parser {
private ArrayList<String> strs;
public ArrayList<String> getStrs() {
return strs;
}
public ArrayList<String> StringsReader(String filename, int wread, int scount) {
int number = 0;
String s;
BufferedReader reader = null;
File f;
strs = new ArrayList<String>();
f = new File(filename);
try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
} catch (FileNotFoundException e) {
System.out.println("File '" + f.getAbsolutePath() + "' - not found!");
}
try {
while ((reader.readLine()) != null) {
number++;
if (number == wread) {
for (int i = 0; i < scount; i++)
if ((s = reader.readLine()) != null)
strs.add(s);
}
}
reader.close();
} catch (IOException e) {
System.out.println("Error reading file: " + f.getAbsolutePath() + "!");
}
return strs;
}
public void ShowStrings(String s) {
System.out.println(s);
}
}