(String[] args)
| 34 | i = in.readInt(); |
| 35 | } |
| 36 | public static void main(String[] args) { |
| 37 | System.out.println("Constructing objects:"); |
| 38 | Blip3 b3 = new Blip3("A String ", 47); |
| 39 | System.out.println(b3); |
| 40 | try( |
| 41 | ObjectOutputStream o = new ObjectOutputStream( |
| 42 | new FileOutputStream("Blip3.serialized")) |
| 43 | ) { |
| 44 | System.out.println("Saving object:"); |
| 45 | o.writeObject(b3); |
| 46 | } catch(IOException e) { |
| 47 | throw new RuntimeException(e); |
| 48 | } |
| 49 | // Now get it back: |
| 50 | System.out.println("Recovering b3:"); |
| 51 | try( |
| 52 | ObjectInputStream in = new ObjectInputStream( |
| 53 | new FileInputStream("Blip3.serialized")) |
| 54 | ) { |
| 55 | b3 = (Blip3)in.readObject(); |
| 56 | } catch(IOException | ClassNotFoundException e) { |
| 57 | throw new RuntimeException(e); |
| 58 | } |
| 59 | System.out.println(b3); |
| 60 | } |
| 61 | } |
| 62 | /* Output: |
| 63 | Constructing objects: |
nothing calls this directly
no test coverage detected