/* This is a simple program that reads a line from a text * */ import java.util.*; import java.io.*; public class ReadLine { 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 the first line of the file String line = input.nextLine(); // Prints the data to the screen System.out.println("The first line in the file is: "); System.out.println(line); // Close the file input.close(); } }