-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReader.java
More file actions
48 lines (33 loc) · 1.21 KB
/
Reader.java
File metadata and controls
48 lines (33 loc) · 1.21 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
47
// Program takes input of strings and parses them for the values
// LAST EDIT was Jacob K. on Feb. 8/2020
import java.util.ArrayList;
import java.nio.file.*;
public class Reader{
String info;
public static void main(String[] args) throws Exception{
String fileName = "FILE.txt";
ArrayList<Double> listR = new ArrayList<Double>();
ArrayList<Double> listV = new ArrayList<Double>();
ArrayList<Double> listX = new ArrayList<Double>();
Path path = Paths.get("./" + fileName);
String fileContents = Files.readString(path);
String[] contList = fileContents.split(",");
String[] processingList;
for (int i = 0; i < contList.length; i++){
processingList = contList[i].split("=");
processingList[0] = processingList[0].strip();
if (processingList[0].equals("r")){
listR.add(Double.parseDouble(processingList[1]));
}
if (processingList[0].equals("v")){
listV.add(Double.parseDouble(processingList[1]));
}
if (processingList[0].equals("x")){
listX.add(Double.parseDouble(processingList[1]));
}
}
System.out.println("R:" + listR);
System.out.println("V:" + listV);
System.out.println("X:" + listX);
}
}