MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

serialization/Blip3.java:36–60  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

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:
63Constructing objects:

Callers

nothing calls this directly

Calls 2

writeObjectMethod · 0.80
readObjectMethod · 0.80

Tested by

no test coverage detected