title: Java Scanner: NoSuchElementException
body: <p>I am having trouble getting my <code>Scanner</code> to work.  It is based on an example my teacher gave us to modify, but I keep getting errors when I run it. When I run it I get this error: </p>
  
  <pre><code>java.util.NoSuchElementException
  at java.util.Scanner.throwFor(Scanner.java:862)
  at java.util.Scanner.next(Scanner.java:1371)
  at ReadDataFile.main(ReadDataFile.java:25)
  </code></pre>
  
  <p>Main Class:</p>
  
  <pre><code>  /**
   * Write a description of class ReadDataFile here.
   * 
   * @author (your name) 
   * @version (a version number or a date)
   */
  import java.io.FileReader;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.util.Scanner;
  import java.util.ArrayList;
  public class ReadDataFile {
      public static void main(String[] args) throws IOException {
  
          Scanner sInputFile=null;
          String FirstName,LastName;
          Float PayRate, HoursWorked;
  
          ArrayList&lt;Employee&gt; Records = new ArrayList&lt;Employee&gt;();
  
          try {
              sInputFile = new Scanner(new BufferedReader(new FileReader("c:\\temp\\inputData.txt")));
              while (sInputFile.hasNextLine()) {
                 FirstName = new String(sInputFile.next());
                 if(FirstName.length() &gt; 9)
                 FirstName = FirstName.substring(0,8);
                 LastName = new String(sInputFile.next());
                 if(LastName.length() &gt; 9)
                 LastName = LastName.substring(0,8);
                 PayRate = sInputFile.nextFloat();
                 HoursWorked = sInputFile.nextFloat();
                 Employee worker = new Employee(LastName,FirstName,PayRate,HoursWorked);
                 Records.add(worker);
              } // while   
  
          } // try
          catch(Exception IOException)
          {
             System.out.println("Unknown file error occurred ...");
          }
          finally { sInputFile.close();}
  
          System.out.print("Complete");
      } // main
  } // class
  </code></pre>
  
  <p>Employee Class:</p>
  
  <pre><code>public class Employee
  {
    String LastName, FirstName;
    float PayRate, HoursWorked, Net, Gross, Tax, TaxRate;
  
    public Employee(String LN, String FN, float Rate, float Hours) 
    {
      LastName = LN;
      FirstName = FN;
      PayRate = Rate;
      HoursWorked = Hours;
      Gross = PayRate * HoursWorked;
      Net = Gross * (1-TaxRate);
      Tax = Gross * TaxRate;
  
    }
  
    public float getPayRate()
    {
        return PayRate;
      }
      public float getHoursWorked()
    {
        return HoursWorked;
      }
      public float getNet()
    {
        return Net;
      }
      public float getGross()
    {
        return Gross;
      }
      public String getLastName()
    {
        return LastName;
      }
      public String getFirstName()
    {
        return FirstName;
      }
    public float getTax()
    {
        return Tax;
      }
  }
  </code></pre>
  
  <p>Here is the text I am trying to read:</p>
  
  <pre><code> Doe   John  13.00  44.5
   Doe   John  13.00  44.5
   Doe   John  13.00  44.5
   Doe   John  13.00  44.5
  </code></pre>