/** * Creates a new serialized object. * * @param toStore the object to store * @param compress whether or not to use compression * @exception Exception if the object couldn't be serialized */ public SerializedObject(Object toStore, boolean compress) throws Exception { ByteArrayOutputStream ostream = new ByteArrayOutputStream(); OutputStream os = ostream; ObjectOutputStream p; if (!compress) p = new ObjectOutputStream(new BufferedOutputStream(os)); else p = new ObjectOutputStream(new BufferedOutputStream(new GZIPOutputStream(os))); p.writeObject(toStore); p.flush(); p.close(); // used to be ostream.close() ! m_storedObjectArray = ostream.toByteArray(); m_isCompressed = compress; m_isJython = (toStore instanceof JythonSerializableObject); }