waterdancer

scanner_line

Jun 26th, 2016
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by charlie on 25/06/2016.
  7.  */
  8. public class PrintFile {
  9.  
  10.  
  11.     public static void main(String... args) {
  12.  
  13.  
  14.         try (Scanner scanner = new Scanner(new File("/Users/charlie/sonnet116.txt"))){
  15.             while (scanner.hasNext())
  16.             System.out.println(scanner.nextLine());
  17.         }catch (FileNotFoundException e){
  18.             System.err.println("Cannot find file");
  19.         }
  20.     }
  21. }
Add Comment
Please, Sign In to add comment