Java 8 ObjectInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ObjectInputStream class.

This code example shows how to use the following methods:readObject
This code example shows how to use the following methods:close, readObject
This code example shows how to use the following methods:readObject
	/** 
	 * Reads the input stream and deserializes into an object. 
	 */ 
	@Override 
	public Object deserialize(InputStream inputStream) throws IOException {
		ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
		try { 
			return objectInputStream.readObject();
		} 
		catch (ClassNotFoundException ex) {
			throw new NestedIOException("Failed to deserialize object type", ex);
		} 
	} 
 
} 
10
CodeRank
This code example shows how to use the following methods:available, close, readObject
        try { 
            ByteBuffer dup = bytes.duplicate();
            int l = dup.remaining();
            ByteArrayInputStream bais = new ByteArrayInputStream(dup.array(),
                    dup.arrayOffset() + dup.position(), l);
            ObjectInputStream ois = new ObjectInputStream(bais);
            Object obj = ois.readObject();
            dup.position(dup.position() + (l - ois.available()));
            ois.close();
            return obj; 
        } catch (Exception ex) {
            throw new SerializationException(ex);
        } 
    } 
 
    public static ObjectSerializer get() { 
        return INSTANCE;
    } 
} 
10
CodeRank
This code example shows how to use the following methods:readObject
This code example shows how to use the following methods:close, readObject
        ObjectInputStream ois = null;
        Object returnObject = null;
        try { 
 
            is = new BufferedInputStream(new FileInputStream(filename));
            ois = new ObjectInputStream(is);
            returnObject = ois.readObject();
 
        } catch (Exception e) {
            e.printStackTrace();
        } finally { 
            try { 
                if (is != null)
                    is.close();
            } catch (Exception e) {
                e.printStackTrace();
            } 
            try { 
                if (ois != null)
                    ois.close();

9
CodeRank
This code example shows how to use the following methods:close, readObject
This code example shows how to use the following methods:readObject
This code example shows how to use the following methods:readInt, readLong, readShort, readUTF
 
	public InternalMessage unmarshall(ObjectInputStream oIn) throws Throwable
	{ 
		InternalMessage message = new InternalMessage();
 
		short version = oIn.readShort();
 
		if (version != VERSION)
		{ 
			String errorMessage = "Incorrect serialization version: " + version;
			log.error(errorMessage);
			throw new Exception(errorMessage);
		} 
		message.setVersion(version);
 
		String string = oIn.readUTF();
		if (string != null)
			message.setCorrelationId(string);
 
		string = oIn.readUTF();

9
CodeRank
This code example shows how to use the following methods:close, readObject

Related Java 8 ObjectInputStream Questions & Answers:

See Code Examples for Java 8 ObjectInputStream Methods: