title: Get matrix from a file Java
body: <p>I currently have a text file in the format</p>
  <pre><code>matrix
  row
  a
  b
  c
  row
  d
  e
  f
  row
  g
  h
  i
  row
  j
  k
  l
  matrix
  row
  m
  n
  o
  p
  q
  row
  r
  s
  t
  u
  v
  </code></pre>
  <p>I would like to convert this into two integer matrices (stored as 2 2D arrays), in the format</p>
  <pre><code>a b c
  
  d e f
  
  g h i
  
  j k l
  </code></pre>
  <p>and</p>
  <pre><code>m n o p q
  
  r s t u v
  
  </code></pre>
  <p>So far, I have created a Scanner object of the file and put each line in a text array:</p>
  <pre><code>Scanner sf = new Scanner(new File(&quot;C:\\textfiles\\matrices.txt&quot;));
  int maxIndex = -1;
  String text[] = new String[10000]; // I added more than necessary for safety
  while (sf.hasNext()){
      maxIndex++;
      text[maxIndex] = sf.nextLine();
  }
  sf.close();
  
  </code></pre>
  <p>This way, the text file is now contained in a string array, where each line is a new element of the array. Right now, I would like to partition the array into two arrays with each array being the matrices. How should I continue? (note: I am a total beginner and desire answers that are simple (no arraylist, hashmap, etc., and that's why this question is not a duplicate of <a href="https://stackoverflow.com/questions/55102669/how-to-read-two-matrices-from-a-txt-file-in-java">How to read two matrices from a txt file in java</a> because it uses BufferedReader, and there are other potential duplicate questions, so I would like to clear this up)</p>
  <p>What I currently have after the top:</p>
  <pre><code>int counter = 0;
  int iCounter = 0; // row
  int jCounter = 0; // column
  
  int matrix1[][];
  int matrix2[][];
  while (counter &lt; maxIndex){
      if (counter = 0)
      {
          \\not yet written...
      }
      \\not yet written...
  }
  </code></pre>