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.");
}
}
}

```

Computer Science & Information Technology

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

Computer Science & Information Technology

The View Borders command allows you to see how a table will display in print

Indicate whether the statement is true or false

Computer Science & Information Technology

The ____ option in Hyper-V Manager to is used to configure hardware.

A. File B. Settings C. Edit D. Configure

Computer Science & Information Technology

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

Computer Science & Information Technology