title: Java - Reading from text file using scanner into a 2D char array
body: <p>I'm trying to read a text file into a 30x30 char array. Scanner does not have a nextChar method, so I'm assuming I'm going to use next() and then split that line into chars? I'm hung up on using 3 for loops to do that though, one for the String, one for rows, and one for columns. </p>
  
  <p>Here is my code so far..</p>
  
  <pre><code>public static void main(String[] args) throws FileNotFoundException {
      final int cellSize = 30; // grid size
      char[][] chargrid = new char[cellSize][cellSize];
      File inputFile = new File("E:\\workspace\\Life2\\bin\\Sample input.txt");
      Scanner in = new Scanner(inputFile);
  
      char testchar;
      while(in.hasNext()){
      String s = in.next();
      for (int i=0; i&lt;s.length();i++){
       testchar = s.charAt(i);
  </code></pre>
  
  <p>Now would I do the 2 for statements for the array row &amp;  columns and then set chargrid[i][j] = testchar for example?</p>
  
  <p>Any help would be appreciated.</p>