Below is the file I am reading the contents from to try and complete the task:
1A STD true false false 23.50 free
1B STD false true false 23.50 free
1D STD true true false 27.50 free
2A STD true false true 24.50 free
2B STD false true true 24.50 free
2D STD true true true 28.50 free
3A STD true false true 24.50 free
3B STD false true true 24.50 free
3D STD true true true 28.50 free
4A STD true false false 23.50 free
4B STD false true false 23.50 free
4D STD true true false 27.50 free
5A 1ST true true true 48.50 free
5C 1ST false true true 44.50 free
5D 1ST true false true 44.50 free
6A 1ST true true true 48.50 free
6C 1ST false true true 44.50 free
6D 1ST true false true 44.50 free
Now my objective is to store all these lines into separate array lists, e.g arrayList1
would be assigned to a value with the contents of the first line of the text file, and then these values are separated and are given the right data type e.g:
- 1A is a string
- true/false statements are assigned to booleans
Then after this reconstruct the file but the contents are assigned not all under one data type such as a string, but their own unique type instead.
int option;
File Seats = new File("seats.txt");
Scanner in = new Scanner(new FileReader(Seats));
String str;
ArrayList<String> list = new ArrayList<String>();
while(in.hasNextLine) {
}
all I have tried so far but receive an error whenever I put anything into the while loop