Assignemnt #127 and Displaying A File
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Displaying A File
///File Name: DisplayingAFile
///Date Finished: 3/29/16
import java.util.Scanner;
import java.io.File;
public class DisplayingAFile
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Open which file: ");
String fileChoice = keyboard.nextLine();
Scanner fileReader = new Scanner(new File(fileChoice));
while(fileReader.hasNext())
{
String line = fileReader.nextLine();
System.out.println( line );
}
}
}
Picture of the output