Assignment #127 and Displaying a File
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Displaying a File
/// File Name: DisplayFile.java
/// Date Finished: 5/17/2016
import java.io.File;
import java.util.Scanner;
public class DisplayFile {
public static void main(String[] args) throws Exception {
Scanner keyboard = new Scanner(System.in);
String choice;
System.out.print( "Open which file: " );
choice = keyboard.next();
Scanner reader = new Scanner(new File(choice));
while(reader.hasNext()) {
System.out.println(reader.nextLine());
}
reader.close();
}
}
Picture of the output