Source of TemperatureShow.java


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