Instead of variables massive1, ..., massive6 a variable lenght List massives would be more suitable:
List<List<Integer>> massives = Arrays.stream(str.split("\\R")) // Stream<String>
.map(line -> Arrays.stream(line.split("\t")) // Stream<String>
.map(field -> Integer::valueOf) // Stream<Integer>
.collect(Collectors.toList())) // List<Integer>
.collect(Collectors.toList()); // List<List<Integer>>
List<int[]> massives = Arrays.stream(str.split("\\R"))
.map(line -> Arrays.stream(line.split("\t"))
.mapToInt(Integer::parseInt)
.toArray())
.collect(Collectors.toList());
Maybe with:
massive1 = massives.get(0);
massive2 = massives.get(1);
massive3 = massives.get(2);
massive4 = massives.get(3);
...
Explanation:
String[] String#split(String regex) would split using the line-break match (\\R) into several lines.
Stream.of / Arrays.stream turns String[] into Stream<String> a kind of iteration through every String.
Stream.map turns turns every String when using Integer::valueOf into an Integer.
Stream.collect collects every Integer into a List.
Streams are very expressive, but might not be suited for total beginners, as they combine all into one single expression, which may easily cause errors.
After understanding the question:
int[][] rows = Stream.of(str.split("\\R"))
.map(line -> Stream.of(line.split("\\s+"))
.mapToInt(Integer.parseInt)
.toArray())
.toArray(int[][]::new);
However one wants the columns:
int m = rows.length;
int n = Arrays.stream(rows).mapToInt(line -> line.length).min().orElse(0);
int[][] columns = IntStream.range(0, n)
.mapToObj(j -> IntStream.range(0, m)
.map(i -> rows[i][j])
.toArray()).toArray(int[][]::new);
System.out.println(Arrays.deepToString(columns));
Actually I advise to convert rows to columns by classical for-loops;
much better readable.
But a StackOverflow answer should not necessarily pick the easiest way.