I have a function that accesses a file and sets each line as a new line in a line in an arraylist. How to create a loop that will go through each row and split the row where "," is present, so that it creates "columns".
Example: file refers to lines
a, 1, 3, b
3, 2, 5, 6
c, b, d, 4
the following will save each line as strings in arraylist
ArrayList<String> result = new ArrayList<String>();
while(input_file.hasNextLine())
{
String line = input_file.nextLine();
result.add(line);
}
from here I'm a little dumb. I know that the next bit of code will take the 1st line of the file "a, 1, 3, b" and split it into new lines in the new arraylist.
String foo = input_file.nextLine();
List<String> myList = new ArrayList<String>(Arrays.asList(foo.split(",")));
, ? , . , , , for-loop n- ( #) if, , , .