title: How to load a 3x3 matrix correctly from data file?
body: <p>I'm working on a Tic-Tac-Toe project, in which I import the 9 character string of X's and O's:</p>
  
  <pre><code>XOOXXOOXX
  </code></pre>
  
  <p>I then have to split it apart, load it into a 3x3 matrix, then test and see who won the game. I have written the code to load the file and run the game like so:</p>
  
  <pre><code>public static void main( String args[] ) throws IOException
  {
      Scanner importer = new Scanner(new File("testdata.dat"));
  
      int count = importer.nextInt();
      System.out.println(count + " games to test.");
  
  
      for(int i = 0; i &lt; count; i++) {
          String game = importer.next();
  
          TicTacToe gamecalc = new TicTacToe();
  
          System.out.println(gamecalc.getWinner(game));
      }
  }
  </code></pre>
  
  <p>However, when I try to load the 3x3 matrix already established like this:</p>
  
  <pre><code>String gamedata = game; //gamedata is passed in, reassigned to game
  
  for(int line = 0; line &lt; 2; line++) {
          for(int column = 0; column &lt; 2; column++) {
  
          gamemat[line][column] = game.charAt(line * column);
  
          }
      }
  </code></pre>
  
  <p>and the data set being:</p>
  
  <pre><code>abcdefghi
  jklmnopqr
  stuvwxyz1
  234567890
  ABCDEFGHI
  </code></pre>
  
  <p>The result ends up being, when printing with Arrays.toString:</p>
  
  <pre><code>[a, a,  ][a, b,  ][ ,  ,  ] //each line is one 3x3 matrix
  [j, j,  ][j, k,  ][ ,  ,  ]
  [s, s,  ][s, t,  ][ ,  ,  ]
  [2, 2,  ][2, 3,  ][ ,  ,  ]
  [A, A,  ][A, B,  ][ ,  ,  ]
  </code></pre>
  
  <p>How can I rework my algorithm to get the matrix to load correctly? Thanks!</p>