Assignemnt #127 Displaying

Code

    /// Name: JJ Deng
    /// Period: 6
    /// Program Name:Displaying A File
    /// File Name: Display.java
    /// Date Finished: 6/1/2016
  
        import java.io.File;
        import java.util.Scanner;
        
        public class Display {
        
            public static void main(String[] args) throws Exception {
        
                String fileName = "";
                Scanner keyboard = new Scanner(System.in);
        
                while (!fileName.equals("exit"))
                {
                    System.out.print("Which file would you like to read from?\n>");
                    fileName = keyboard.next();
        
                    if (!fileName.equals("exit"))
                    {
                        System.out.print("File \"" + fileName + "\":\n\n");
        
                        Scanner fileIn = new Scanner(new File(fileName));
        
                        while(fileIn.hasNext())
                        {
                            System.out.println(fileIn.nextLine());
                        }
        
                        fileIn.close();
        
                        System.out.println("\n\n Done.\n");
                    }
                }
            }
        }

    

Picture of the output

Assignment 120