Write a complete Java program using a Scanner object that opens a file named autos.txt and displays each line to the screen.
What will be an ideal response?
```
import java.util.*;
import java.io.FileReader;
import java.io.FileNotFoundException;
public class TextDemo
{
public static void main(String args[])
{
Scanner inputStream = null;
try
{
inputStream = new Scanner(new FileReader("autos.txt"));
String line = inputStream.nextLine();
while(line != null)
{
System.out.println(line);
line = inputStream.nextLine();
}
inputStream.close();
}
catch(FileNotFoundException e)
{
System.out.println("Error opening files.");
}
}
}
```
You might also like to view...
Which network topology is shown here?
a. Star
b. Token Ring
c. Bus
d. Mesh
e. None of these answers is correct.
Clicking the ________ button, found in the Proofing group,will display the document statistics which include the number of pages, number of words, paragraphs, lines and characters
A) Character Count B) Page Count C) Word Count D) Paragraph Count
What is the correct HTML for making a drop-down list?
What will be an ideal response?
A record is another term for a(n) ____.
A. tuple B. field C. attribute D. property