title: reading from file into 2D array
body: <p>I have to read data from a file like this:</p>
  
  <pre><code>4
  192 48 206 37 56
  123 35 321 21 41
  251 42 442 32 33
  </code></pre>
  
  <p>the first number is the total number of candidates(columns) and i need to store that value for other use. Then i need to read the rest of the data into a 2D array. I updated my code with what i have now but it still not working. I keep getting the error 
  java.util.NoSuchElementException: No line found</p>
  
  <pre><code> public static int readData(int[][] table, Scanner in)throws IOException
  {
  System.out.println("Please enter the file name: ");
   String location = in.next();
   Scanner fin = new Scanner(new FileReader(location));
   int candidates = fin.nextInt();
   fin.nextLine();
  for (int row = 0; row &lt; 5; row++) {
    for (int column = 0; column &lt; candidates; column++) {
      String line = fin.nextLine();
      fin.nextLine();
      String[] tokens = line.split(" ");
      String token = tokens[column];
      table[row][column] = Integer.parseInt(token);
    }
  }
  fin.close();
  return candidates;
  }
  
  }
  </code></pre>