Assignment #127

Code

/// Name: Jonathan Stine
/// Period: 5
/// Program Name: Displaying a File
/// File Name: DisplayingFile.java
/// Date Finished: 3/3/2016
    
    import java.io.File;
    import java.util.Scanner;
    
    public class DisplayingFile {
        
        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();
        }
    }
    
 
    

Code Output