I just wanted to ask, let say we have 10 lines in a txt file and each include diffrent kind of numbers. And I want to put the numbers in each line on a different arraylists. what can I do for it? Here is the example:
31 44 43 43 43 43 43 45 45 45 44 45 45 45 46 46 45 45 46 46 46 45 45 45 45 45 44 45 45 45 45 46 29 47 46 48 49 48 49 49 49 48 49 49 50 48 48 48 49 49 49 49 50 50 50 50 50 50 49 51 51 51 31 49 50 48 49 50 51 51 52 52 52 52 51 52 52 52 52 53 53 54 54 54 54 54 54 53 53 53 54 55 55 54 30 54 54 56 56 56 56 56 56 57 57 57 57 57 57 58 58 56 57 57 58 58 58 58 58 59 60 60 60 61 62 31 60 59 61 61 62 62 63 62 62 62 64 64 64 64 64 66 65 66 65 65 65 65 66 67 67 66 66 67 66 66 67 30 68 69 68 68 69 67 67 68 69 68 68 68 69 69 69 69 71 71 71 70 71 70 70 70 72 71 71 71 71 72 31 70 72 73 73 72 73 74 74 74 73 75 76 75 75 75 75 76 77 76 76 77 76 76 76 77 77 78 77 77 77 77 31 75 75 76 76 75 76 77 78 79 77 77 77 75 75 74 73 76 75 74 75 74 74 73 73 73 73 72 74 74 72 72 30 72 73 73 73 72 72 71 71 71 71 70 71 72 71 68 68 68 68 67 68 69 69 68 67 67 66 67 66 66 66 public static void main(String[] args) throws IOException {
List<int[]> arrays = new ArrayList<int[]>();
BufferedReader reader = new BufferedReader(new FileReader("weather.txt"));
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
String[] intStrings = line.split(" ");
int[] ints = new int[intStrings.length];
for (int i = 0; i < ints.length; ++i) {
ints[i] = Integer.parseInt(intStrings[i]);
}
arrays.add(ints);
}`enter code here`
for (int[] name : arrays) {
System.out.println(name);
}
}
}