Here is our sample solution for the class Read_a_File:
import java.io.*;
import java.util.*;
public class Read_a_File
{
public void run() throws IOException
{
String line;
// Create a Scanner instance here. The filename is "sample1.txt"
Scanner sc = new Scanner(new File("sample1.txt"));
while (sc.hasNext())
{
// Write code here to display each line and then read the next one.
line = sc.nextLine();
System.out.println(line);
}
sc.close();
}
}