Code example for ObjectInputStream

Methods: defaultReadObject, readFully, readInt

0
        } 
    } 
 
    private void readObject(ObjectInputStream in)
            throws ClassNotFoundException, IOException { 
        in.defaultReadObject();
        int len = in.readInt();
        if (len == -1) {
            StreamManager sm = Framework.getLocalService(StreamManager.class);
            if (sm == null) {
                throw new IOException(
                        "There is no streaming service registered"); 
            } 
            String uri = in.readUTF();
            src = sm.getStream(uri);
        } else { 
            byte[] bytes = new byte[len];
            in.readFully(bytes);
            src = new ByteArraySource(bytes);
        } 
    } 
 
}