previous | start | next

## Serialization

- Save collection of objects to stream

      Employee[] staff = new Employee[2];

      staff.add(new Employee(...));

      staff.add(new Employee(...));

- Construct `ObjectOutputStream`:

      ObjectOutputStream out

         = new ObjectOutputStream(

            new FileOutputStream("staff.dat"));

- Save the array and close the stream

      out.writeObject(staff);

      out.close();

previous | start | next