title: Input.Java.Mismatch error: Null for text file
body: <p>So I looked at other answers and I did not find a solution to my question.
  I'm new to Java so don't expect complex methods, I'll show what's in the text file and a few methods, thanks :)
  By the way, it's a runtime error.</p>
  
  <p>Text File:</p>
  
  <pre><code>1.1206060982385907E-23 
  1.8211358653686147E-24 
  1.6396713341496784E-24 
  5.76142040175542E-24 
  1.305001288660403E-26
  1.8362146624686452E-26
  1.0207894499723824E-25
  1.0867598055339296E-25 
  4.670786575865269E-23 
  </code></pre>
  
  <p>Main Method:</p>
  
  <pre><code>public static void main(String[] args)throws IOException
  {
      // Extension idea... instead of hard codeing the weight, you may propt the user for input.
      // Initialize Variables
      double[] gravity = new double[9];
      File fileRead = new File("/Users/jerome/Desktop/Gravity.txt");
      Scanner inFile = new Scanner (fileRead); 
      for (int i = 0; i&lt;9; i ++)
      {
        gravity[i] = inFile.nextDouble(); // Fails here
  
      }
      inFile.close();
      double earthWeight = 100.0; // initalize Earth weight to 100 lbs.
      String[] names = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"};
      // Processing
      double[] weights = calcWeight(earthWeight, gravity);  // static method you write
  
      // Output
      printResults(names, gravity, weights);
  
  
  } //end main
  }//end class
  </code></pre>
  
  <p>Printing to Screen:</p>
  
  <pre><code>public static void printResults(String[] name,double gravity[],double weights[])
  {
          System.out.printf("%25s %n","My Weight on the Planets");
          System.out.printf("%10s %13s %13s %n"," Planet","Gravity","Weight (lbs)");
          System.out.printf("%s %n","================================================");
          for (int i = 0; i&lt;9; i ++)
          {
              System.out.printf("%10s %13s %13s %16s %n",name[i],gravity[i],weights[i]);
          }
  }
  </code></pre>
  
  <p>Gravity calculation:</p>
  
  <pre><code>public static double[] calcWeight(double earthWeight,double[] gravity)
  {
          double[] calcWeight = new double[9];
  
          for (int i=0; i&lt;9; i++)
          {
              calcWeight[i] = earthWeight * gravity[i];
          }
          return calcWeight;
  }
  </code></pre>