-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParser.java
More file actions
46 lines (40 loc) · 903 Bytes
/
Copy pathParser.java
File metadata and controls
46 lines (40 loc) · 903 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
35
36
37
38
39
40
41
42
43
44
45
46
import java.io.*;
import java.util.*;
class Parser
{
public static ArrayList<ArrayList<String>> data = new ArrayList<>();
public static void read(String arg)
{
data.clear();
Scanner sc = null;
try
{
sc = new Scanner(new File(arg));
}catch(Exception e){}
sc.nextLine();
while(sc.hasNextLine())
{
String line = sc.nextLine();
int k = 1;
ArrayList<String> columns = new ArrayList<>();
while(k<line.length())
{
int index = line.indexOf('"',k);
String temp = line.substring(k, index).trim();
columns.add(temp);
k = index+3;
}
data.add(columns);
}
}
public static long getNumber(String s, boolean seq)
{
if((seq&&s.indexOf("Seq")==-1)||(!seq&&s.indexOf("Ack")==-1)) return -1;
if(seq)
s = s.substring(s.indexOf("Seq")+4);
else
s = s.substring(s.indexOf("Ack")+4);
Scanner sc = new Scanner(s);
return sc.nextLong();
}
}