fork download
  1. import java.util.*;
  2.  
  3. class Ideone {
  4. public static void main (String[] args) {
  5. // using Arrays.stream instead of Files.lines() because files not available here
  6. int[][][] array = Arrays.stream("013 234 456 567\n111 222 333 444".split("\n"))
  7. .map(line -> Arrays.stream(line.split(" ")) // split line into terms
  8. .map(term -> term.chars().map(Character::getNumericValue).toArray()) // convert each term to int[]
  9. .toArray(int[][]::new)) // convert each line to int[][]
  10. .toArray(int[][][]::new); // convert all lines of file to int[][][]
  11. System.out.println(Arrays.deepToString(array));
  12.  
  13. }
  14. }
Success #stdin #stdout 0.09s 42588KB
stdin
Standard input is empty
stdout
[[[0, 1, 3], [2, 3, 4], [4, 5, 6], [5, 6, 7]], [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]]