I have a text file containing the following content:
0 12
1 15
2 6
3 4
4 3
5 6
6 12
7 8
8 8
9 9
10 13
I want to read these integers from data.txt file and save the two columns into two different arrays in Java.
I am a beginner in Java, and thank you for your help.
Unless you know the number of lines in the file in advance, I suggest you collect the numbers in two
Lists, such asArrayList<Integer>.Something like this should do the trick:
If you really need the numbers in two
int[]arrays you can create the arrays afterwards (when the size is known).