public class Question29
1: //Question29.java
2:
3: import java.io.ObjectInputStream;
4: import java.io.EOFException;
5: import java.io.FileInputStream;
6: import java.io.IOException;
7:
8: public class Question29
9: {
10: public static final String FILE_NAME = "temperatures.dat";
11: public static void main(String[] args)
12: {
13: try
14: {
15: ObjectInputStream inputStream =
16: new ObjectInputStream(new FileInputStream(FILE_NAME));
17: System.out.println("Numbers from the file " + FILE_NAME + ":");
18: try
19: {
20: while (true)
21: {
22: double number = inputStream.readDouble();
23: System.out.println(number);
24: }
25: }
26: catch (EOFException e)
27: {
28: //Do nothing
29: }
30: System.out.println("End of reading from file.");
31: inputStream.close();
32: }
33: catch (IOException e)
34: {
35: System.out.println("Problem reading from file.");
36: }
37: }
38: }