dis

    import java.io.File;
    import java.util.Scanner;
    
    public class dis
    {
        
        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();
        }
    }
    

Picture of the output