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
            final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            final ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(t1);
            out.close();
 
            final ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
            t2 = (StandardGradientPaintTransformer) in.readObject();
            in.close();
        } 
        catch (Exception e) {
            System.out.println(e.toString());
        } 
        assertTrue(t1.equals(t2)); 
 
    } 
 
} 
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readObject
            String managementPort;
            String address;
            String protocol;
            try { 
                in = resourceUrl.openStream();
                ObjectInputStream inputStream = new ObjectInputStream(in);
                managementPort = (String) inputStream.readObject();
                address = (String) inputStream.readObject();
                protocol = (String) inputStream.readObject();
                if (address == null) {
                    address = "localhost";
                } 
                if (managementPort == null) {
                    managementPort = "9990";
                } 
                if (protocol == null) {
                    protocol = "http-remoting";
                } 
                ModelControllerClient modelControllerClient = null;
                final int port = Integer.parseInt(managementPort);
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, readObject
This code example shows how to use the following methods:readObject
		oos.flush();
		baos.flush();
		byte[] bytes = baos.toByteArray();
 
		ByteArrayInputStream is = new ByteArrayInputStream(bytes);
		ObjectInputStream ois = new ObjectInputStream(is);
		Object o2 = ois.readObject();
		return o2; 
	} 
 
} 
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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: