title: Reading from a File - Wrong File Type?
body: <p>I am having trouble reading from a simple text file and cannot seem to figure out why.  I have done this before, and I am unsure as to what the issue is.  Any help would be appreciated!</p>
  
  <pre><code>import java.io.File;
  import java.util.Scanner;
  
  public class CS2110TokenReader {
  
      /**
       * @param args
       */
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
          File theFile = new File("data1.txt");
          Scanner scnFile = new Scanner(theFile);
  
          try {
              scnFile = new Scanner(theFile);
          } catch (Exception e) {
              System.exit(1);
          }
          while (theFile.hasNext()) {
              String s1 = theFile.next();
              Double d1 = theFile.nextDouble();
  
              System.out.println(s1 + "   " + d1);
          }
  
      }
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
      The method hasNext() is undefined for the type File
      The method next() is undefined for the type File
      The method nextDouble() is undefined for the type File
  
      at CS2110TokenReader.main(CS2110TokenReader.java:20)
  </code></pre>
  
  <hr>
  
  <p>It will not even scan for the next line.  That is my objective.  To scan and read.</p>