Assignment #127

Code

    /// Name: Matthew Lorence
    /// Period: 5
    
    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 file = keyboard.next();
            
            Scanner fileIn = new Scanner( new File(file));
            
            while (fileIn.hasNext())
                {
                    String print = fileIn.nextLine();
                    System.out.println(print);
                }
                fileIn.close();
         }
    }

        
        
    

Picture of the output

Assignment 127