Code example for Scanner

Methods: close, hasNext, next

0
    s.close();
  } 
 
  static void readFile() { 
    try { 
      Scanner darkly = new Scanner(new File("./classes/test/ScannerTest.java"));
      System.out.println(darkly.hasNext());
      System.out.println(darkly.next());
      System.out.println(darkly.next());
      System.out.println(darkly.next());
      darkly.close();
    } catch (FileNotFoundException e) {
      System.out.println(e);
    } 
  } 
 
  public static void main(String[] args) {
    readFile(); 
    useDelimiters(); 
    useRegex(); 
  }