-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadLimits.java
72 lines (65 loc) · 2.22 KB
/
ReadLimits.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class ReadLimits {
public static limitsHzDb read(String csvFile) throws IOException {
BufferedReader br = null;
limitsHzDb out = new limitsHzDb(0);
try {
String line = "";
String csvSplitBy = ",";
int len = 0;
int count = 0;
// extend output
br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {
len++;
}
br.close();
br = new BufferedReader(new FileReader(csvFile));
out.extend(len - 5);
// read values
while ((line = br.readLine()) != null) {
String[] lineRead = line.split(csvSplitBy);
if (count == len) {
break;
}
switch (count) {
case 0:
out.smoothingBwBins = Integer.parseInt(lineRead[0]);
break;
case 1:
out.noiseLimitDb = Integer.parseInt(lineRead[0]);
break;
case 2:
out.recLenSec = Double.parseDouble(lineRead[0]);
break;
case 3:
out.disregardSecs = Integer.parseInt(lineRead[0]);
break;
case 4:
out.pauseSecs = Integer.parseInt(lineRead[0]);
break;
default: {
out.toleranceHz[count - 5] = Integer.parseInt(lineRead[0]);
out.toleranceDb[count - 5] = Integer.parseInt(lineRead[1]);
}
}
count++;
}
} catch (IOException e) {
e.printStackTrace();
throw e;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
throw e;
}
}
}
return out;
}
}