package eecs1022; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import javax.swing.JOptionPane; public class PrintFile { public static void main(String[] args) { Scanner input = null; do { try { String name = JOptionPane.showInputDialog("File name"); File file = new File(name); input = new Scanner(file); } catch (FileNotFoundException e) { // do nothing } } while (input == null); while (input.hasNextLine()) { String line = input.nextLine(); System.out.println(line); } input.close(); } }