Write a complete Java program using a BufferedReader object that opens a file named autos.txt and displays each line to the screen.
What will be an ideal response?
```
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;
public class TextDemo
{
public static void main(String args[])
{
BufferedReader inputStream = null;
try
{
inputStream = new BufferedReader(new FileReader("autos.txt"));
String line = inputStream.readLine();
while(line != null)
{
System.out.println(line);
line = inputStream.readLine();
}
inputStream.close();
}
catch(FileNotFoundException e)
{
System.out.println("Error opening files.");
}
catch(IOException e)
{
System.out.println("Error reading from file.");
}
}
}
```
You might also like to view...
When a ________ within a form or report is deleted, only that object is deleted, not the actual form or report
A) button B) cursor C) tab D) data type
The View Borders command allows you to see how a table will display in print
Indicate whether the statement is true or false
The ____ option in Hyper-V Manager to is used to configure hardware.
A. File B. Settings C. Edit D. Configure
Which packet-switched technology use cells that are always a fixed length of 53 bytes?
a. Frame Relay b. x.25 c. ISDN d. ATM