Assignemnt #127 and DisplayingFile
Code
/// name: Leila Ordukhani
/// period: 6
/// program name: One Hundred and Seven Program
/// file name: DisplayingFile.java
/// date finished: 5/31/16
import java.io.File;
import java.util.Scanner;
public class DisplayingFile {
public static void main(String[] args) throws Exception {
String file;
Scanner k = new Scanner(System.in);
System.out.print("Open which file: ");
file = k.next();
Scanner fileReader = new Scanner(new File(file));
while(fileReader.hasNext()) {
String line = fileReader.nextLine();
System.out.println(line);
}
fileReader.close();
}
}
Picture of the output