ObjectInputStream readObject - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ObjectInputStream readObject method.

This code example shows how to use the following methods: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: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:readObject
 * The main entry point for a worker process. Reads a serialized Callable from stdin, and executes it. 
 */ 
public class GradleWorkerMain { 
    public void run() throws Exception {
        // Read the main action from stdin and execute it 
        ObjectInputStream instr = new ObjectInputStream(new EncodedStream.EncodedInput(System.in));
        Callable<?> main = (Callable<?>) instr.readObject();
        main.call();
    } 
 
    public static void main(String[] args) {
        try { 
            new GradleWorkerMain().run(); 
            System.exit(0);
        } catch (Throwable throwable) {
            throwable.printStackTrace(System.err);
            System.exit(1);
        } 
    } 
} 
9
CodeRank
This code example shows how to use the following methods:readObject
    } 
 
    @Override 
    public Object deserializeModelTestOperationValidatorFilter(byte[] object) throws IOException, ClassNotFoundException {
        ByteArrayInputStream bin = new ByteArrayInputStream(object);
        ObjectInputStream in = new ObjectInputStream(bin);
        Object o = null;
        try { 
            o = in.readObject();
        } finally { 
            IoUtils.safeClose(in);
            IoUtils.safeClose(bin);
        } 
        return o;
    } 
} 
10
CodeRank
This code example shows how to use the following methods:close, readObject
    } 
  } 
 
  private void loadFromInputStream(InputStream serialObjectInputStream)
      throws IOException, ClassNotFoundException {
    ObjectInputStream input = new ObjectInputStream(serialObjectInputStream);
    bigramHashTable = (long[]) input.readObject();
    frequencyTable = (int[]) input.readObject();
    // log.info("load bigram dict from serialization."); 
    input.close();
  } 
 
  private void saveToObj(Path serialObj) {
    try { 
      ObjectOutputStream output = new ObjectOutputStream(Files.newOutputStream(
          serialObj));
      output.writeObject(bigramHashTable);
      output.writeObject(frequencyTable);
      output.close();
      // log.info("serialize bigram dict."); 
8
CodeRank
This code example shows how to use the following methods:readObject
    public Object readObject() { 
 
        ObjectInputStream reader = null;
 
        try { 
            reader = new ObjectInputStream(socket.getInputStream());
        } catch (SocketException e) {
            if (!isIgnorableException(e)) {
                logger.error("Reading Object", e);
            } 
            return null; 
        } catch (Exception e) {
            logger.error("Reading Object", e);
            return null; 
        } 
 
        try { 
            return reader.readObject();
        } catch (SocketException e) {
            //a connection reset is normal if the client quits, so don't dump out this exception and just return null. 

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

Related ObjectInputStream readObject Questions & Answers:

readObject Method Overview
Read an object from the ObjectInputStream.
See Code Examples for other Java 8 ObjectInputStream Methods: