Assignment #127 DisplayingAWholeFile
Code
/// Name: Lacey Reese
/// Period: 5
/// Program Name: DisplayingAWholeFile
/// File Name: DisplayingAWholeFile.java
/// Date Finished 5/27/2016
import java.io.File;
import java.util.Scanner;
public class DisplayingAFile
{
public static void main(String[] args) throws Exception {
Scanner keyboard = new Scanner(System.in);
System.out.println();
System.out.print( "Open which file: " );
String file = keyboard.next();
Scanner reader = new Scanner(new File(file));
while(reader.hasNext()) {
String w = reader.nextLine();
System.out.println( w + " " );
}
reader.close();
}
}
Picture of the output
//