(String[] args)
| 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: |
| 55 | Before: |
nothing calls this directly
no test coverage detected