/* This is a simple program that reads until the end of file * */ import java.util.*; import java.io.*; public class DetectEndOfFile { public static void main(String[] args)throws IOException { Scanner key = new Scanner(System.in); // Gets the name of the file System.out.println("Enter the name of the file:"); String filename = key.nextLine(); // Opens the file File file = new File(filename); Scanner input = new Scanner(file); // Reads until end of file while (input.hasNext()) { // Read a single line from the file String line = input.nextLine(); // Prints the data to the screen System.out.println(line); } // Close the file input.close(); } }