// Get the bytes of the serialized object
byte[] bytes = bos.toByteArray( );
// Deserialize from a byte array
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream( bytes ) );
WorkingMemory workingMemoryOut = ( WorkingMemory ) in.readObject( );
in.close( );
return workingMemoryOut;
}