-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDataProcessor.java
52 lines (46 loc) · 1.69 KB
/
DataProcessor.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
48
49
50
51
52
import java.io.*;
import java.util.*;
/**
* Process the data from the files specified in Constants.java
* @author Shalin Shah
* Email: [email protected]
*/
public class DataProcessor
{
/** Process the data */
public static void processData() throws Exception
{
Constants.VALUES = new int [Constants.NUMBER_OBJECTS];
Constants.WEIGHTS = new int [Constants.NUMBER_OBJECTS];
File weights = new File(Constants.DATA_FILE_WEIGHTS);
File values = new File(Constants.DATA_FILE_VALUES);
BufferedReader wreader = new BufferedReader(new FileReader(weights));
BufferedReader vreader = new BufferedReader(new FileReader(values));
String buffer = wreader.readLine();
int i = 0;
while(buffer != null && i < Constants.NUMBER_OBJECTS)
{
StringTokenizer token = new StringTokenizer(buffer, Constants.DELIMITER);
while(token.hasMoreTokens() && i < Constants.NUMBER_OBJECTS)
{
String tok = token.nextToken();
tok = tok.trim();
Constants.WEIGHTS[i] = Integer.parseInt(tok);
i++;
}
}
buffer = vreader.readLine();
i = 0;
while(buffer != null && i < Constants.NUMBER_OBJECTS)
{
StringTokenizer token = new StringTokenizer(buffer, Constants.DELIMITER);
while(token.hasMoreTokens() && i < Constants.NUMBER_OBJECTS)
{
String tok = token.nextToken();
tok = tok.trim();
Constants.VALUES[i] = Integer.parseInt(tok);
i++;
}
}
}
}