So, the input looks like this:
1 2
3 4
5 6
7 8
And I need to store each line as an array, like this:
[1, 2]
[3, 4]
[5, 6]
[7, 8]
I guess I can do this with .componentsSeparatedByString(" ")
and then converting each element to an integer.
The problem is, I've tried using readLine()
, but it only stores the first line, 1 2. I've thought about doing a while loop, but my input can contain more than 50 lines, and entering every single line would be pretty inconvenient.
Is there a way to store several lines as a string at once? It would also be good if I could replace the line breaks with ;
, but I have no idea how, since it only stores the first line. Any help would be appreciated.
Thanks in advance!