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

Method main

serialization/Logon.java:24–49  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

22 "\n password: " + password;
23 }
24 public static void main(String[] args) {
25 Logon a = new Logon("Hulk", "myLittlePony");
26 System.out.println("logon a = " + a);
27 try(
28 ObjectOutputStream o =
29 new ObjectOutputStream(
30 new FileOutputStream("Logon.dat"))
31 ) {
32 o.writeObject(a);
33 } catch(IOException e) {
34 throw new RuntimeException(e);
35 }
36 new Nap(1);
37 // Now get them back:
38 try(
39 ObjectInputStream in = new ObjectInputStream(
40 new FileInputStream("Logon.dat"))
41 ) {
42 System.out.println(
43 "Recovering object at " + new Date());
44 a = (Logon)in.readObject();
45 } catch(IOException | ClassNotFoundException e) {
46 throw new RuntimeException(e);
47 }
48 System.out.println("logon a = " + a);
49 }
50}
51/* Output:
52logon a = logon info:

Callers

nothing calls this directly

Calls 2

writeObjectMethod · 0.80
readObjectMethod · 0.80

Tested by

no test coverage detected