-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCar_read.java
32 lines (27 loc) · 939 Bytes
/
Car_read.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
import java.io.IOException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;
public class Car_read {
public static void read(){
try {
System.out.println("Information:");
System.out.printf("%-5s %-15s %-15s %-15s %-15s %-15s %-10s\n", "ID", "Model", "Manufacturer", "Model_Year",
"Price", "Class","Units");
JSONArray jsonArray = Read_Json.readJsonArrayFromFile("Car_DataStorage.json");
for (Object object : jsonArray) {
JSONObject obj = (JSONObject) object;
System.out.printf("%-5s %-15s %-15s %-15s %-15s %-15s %-10s \n",
obj.get("ID"),
obj.get("Model"),
obj.get("Manufacture"),
obj.get("Year"),
obj.get("Price"),
obj.get("Class"),
obj.get("Units"));
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
}
}