Code example for ObjectOutputStream

Methods: defaultWriteObject, write, writeInt, writeUTF

0
        } 
        return this;
    } 
 
    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
        long len = src.getLength();
        StreamManager sm = Framework.getLocalService(StreamManager.class);
        if (sm == null || (len > -1 && len <= MEM_MAX_LIMIT)) {
            // use in memory buffers for less than 1MB of data or if no 
            // streaming service is available 
            byte[] bytes = src.getBytes();
            out.writeInt(bytes.length);
            out.write(bytes);
        } else { 
            out.writeInt(-1); // marker how many bytes follows - if -1 => an
            // URI follow 
            String uri = sm.addStream(src);
            out.writeUTF(uri);
        } 
    } 
 
    private void readObject(ObjectInputStream in)
            throws ClassNotFoundException, IOException {