title: Scan array of doubles in a file | Java
body: <p>I was trying to scan a file that has an array of doubles. I'm using the code below but it's only outputting <code>0.0</code> for every entry. Why is this and how can I fix it?</p>
  
  <pre><code>Scanner scanner = new Scanner("file.txt");
  double[] array = new double[256 * 256];
  for (int i = 0; i &lt; array.length; i++) {
      if (scanner.hasNextDouble()) {
          array[i] = scanner.nextDouble();
      }
  }
  System.out.println(array[0]);
  </code></pre>
  
  <p>An example of the file I'm scanning is </p>
  
  <pre><code>0.22131145 0.22131145 0.22131145 0.22841525 0.22841525 ...
  </code></pre>