I'm trying to figure out how to write the data like this : {"Temperature" = 19.7, "Humidity" = 11, "day"=1, "month" = 3, "year"=1995}
Where i'm struggling is how split the data and use it, should i make a new arrayList, or i can split it inside the same array?
data from txt file:
19.7|11|1/1/1995
12.0|12|2/1/1995
14.6|11|3/1/1995
10.1|10|4/1/1995
My program:
ArrayList<String> weather = new ArrayList<String>();
while (scanner.hasNextLine()){
String line = scanner.nextLine();
String [] splittedString = line.split("|");
System.out.print(" \"Tempreture\" = "+splittedString[0]);
System.out.print(", \"Humidity\" = "+splittedString[1]);
String [] splitDate = line.split("/");
System.out.print(" \"day\"= "+splitDate[2]);
System.out.print(" \"month\"= "+splitDate[3]);
System.out.print(" \"year\"= "+splitDate[4]);
weather.add(splittedString[3]);
for (int i=4;i<splittedString.length;i++){
System.out.print(splittedString[i]+", ");