Write a complete Java program that opens a binary file containing integers and displays the contents to the screen.
What will be an ideal response?
```
import java.io.ObjectInputStream;
import java.io.FileInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.FileNotFoundException;
public class BinaryInputDemo
{
public static void main(String args[])
{
try
{
ObjectInputStream inputStream =
new ObjectInputStream(new
FileInputStream("statistics.dat"));
int stat = 0;
try
{
while(true)
{
stat = inputStream.readInt();
System.out.println(stat);
}
}
catch(EOFException e)
{
System.out.println("End of file encountered");
}
inputStream.close();
}
catch(FileNotFoundException e)
{
System.out.println("Unable to locate file");
}
catch(IOException e)
{
System.out.println("Unable to read file");
}
}
}
```
You might also like to view...
What is the point of an inspection review?
What will be an ideal response?
For C++ programs, why is the stack an important part of the RAM?
What will be an ideal response?
If you are artistic and have mastered software packages such as Adobe Photoshop, Autodesk 3ds Max, and Autodesk Maya, you might consider a career as which of the following?
a. game programmer c. game tester b. game designer d. web designer
Discuss the use of hex codes and RGB triplets for defining color.
What will be an ideal response?