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

Method main

serialization/SerialCtl.java:29–52  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

27 b = (String)stream.readObject();
28 }
29 public static void main(String[] args) {
30 SerialCtl sc = new SerialCtl("Test1", "Test2");
31 System.out.println("Before:\n" + sc);
32 try (
33 ByteArrayOutputStream buf =
34 new ByteArrayOutputStream();
35 ObjectOutputStream o =
36 new ObjectOutputStream(buf);
37 ) {
38 o.writeObject(sc);
39 // Now get it back:
40 try (
41 ObjectInputStream in =
42 new ObjectInputStream(
43 new ByteArrayInputStream(
44 buf.toByteArray()));
45 ) {
46 SerialCtl sc2 = (SerialCtl)in.readObject();
47 System.out.println("After:\n" + sc2);
48 }
49 } catch(IOException | ClassNotFoundException e) {
50 throw new RuntimeException(e);
51 }
52 }
53}
54/* Output:
55Before:

Callers

nothing calls this directly

Calls 2

writeObjectMethod · 0.80
readObjectMethod · 0.80

Tested by

no test coverage detected