ObjectOutputStream close - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:close, writeObject
	@Override 
	public Object deepCopy(Object value) throws HibernateException {
		try { 
			// Write to new byte array to clone. 
			ByteArrayOutputStream baos = new ByteArrayOutputStream(OUTPUT_BYTE_ARRAY_INITIAL_SIZE);
			ObjectOutputStream oos = new ObjectOutputStream(baos);
			try { 
				oos.writeObject(value);
			} 
			finally { 
				oos.close();
			} 
 
			// Read it back and return a true copy. 
			ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
			ObjectInputStream ois = new ObjectInputStream(bais);
			try { 
				return ois.readObject();
			} 
			finally { 
10
CodeRank
This code example shows how to use the following methods:close, writeObject
    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."); 
    } catch (Exception e) {
      // log.warn(e.getMessage()); 
    } 
  } 
 
  private void load() throws IOException, ClassNotFoundException {
    InputStream input = this.getClass().getResourceAsStream("bigramdict.mem");
    loadFromInputStream(input);
  } 
9
CodeRank
This code example shows how to use the following methods:close, writeObject
 
    @Override 
    public ByteBuffer toByteBuffer(Object obj) {
        try { 
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(obj);
            oos.close();
 
            return ByteBuffer.wrap(baos.toByteArray());
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        } 
    } 
 
    @Override 
    public Object fromByteBuffer(ByteBuffer bytes) {
        if ((bytes == null) || !bytes.hasRemaining()) {
            return null; 
        } 
9
CodeRank
This code example shows how to use the following methods:close, writeBoolean, writeInt, writeObject
8
CodeRank
This code example shows how to use the following methods:close, writeChar, writeLong, writeUTF
        assertTrue( thingy.equals(unmaThingy) );
    } 
 
    private byte [] marshallThingy(DataObject thingy ) throws IOException { 
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream stream = new ObjectOutputStream(baos);
 
        stream.writeChar(thingy.type);
        stream.writeLong(thingy.time);
        if( thingy.intCount != null ) { 
            stream.writeInt(thingy.intCount);
        } 
        else if( thingy.strCount != null ) { 
            stream.writeUTF(thingy.strCount);
        } 
        else {  
            throw new IllegalStateException("Neither the integer nor String count is filled." );
        } 
        stream.close();
 

8
CodeRank
This code example shows how to use the following methods:close, writeObject
ByteArrayOutputStream outStream;
        try 
        { 
            outStream = new ByteArrayOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(outStream);
            out.writeObject(object);
            out.close();
        } 
        catch (IOException e)
        { 
            throw new NamingException(e.getMessage());
        } 
 
        BinaryRefAddr handle = new BinaryRefAddr("com.impetus.kundera.persistence.jta", outStream.toByteArray());
        Reference ret = new Reference(object.getClass().getName(), handle, UserTransactionFactory.class.getName(), null);
        return ret;
    } 
} 
9
CodeRank
This code example shows how to use the following methods:close, writeObject
    SenseiRequestBPO.Request.Builder builder = SenseiRequestBPO.Request.newBuilder();
    try 
    { 
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos;
      oos = new ObjectOutputStream(baos);
      oos.writeObject(req);
      oos.close();
      byte[] raw = baos.toByteArray();
      builder.setVal(ByteString.copyFrom(raw));
      return builder.build();
    } catch (IOException e)
    { 
      logger.error("deserialize request", e);
    } 
    return SenseiRequestBPO.Request.getDefaultInstance(); 
  } 
  public static SenseiResult convert(SenseiResultBPO.Result req)
  { 
    try 
9
CodeRank
This code example shows how to use the following methods:close, flush, writeObject
This code example shows how to use the following methods:close, writeObject
		SenseiSysRequestBPO.SysRequest.Builder builder = SenseiSysRequestBPO.SysRequest.newBuilder();
		try 
		{ 
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			ObjectOutputStream oos;
			oos = new ObjectOutputStream(baos);
			oos.writeObject(req);
			oos.close();
			byte[] raw = baos.toByteArray();
			builder.setVal(ByteString.copyFrom(raw));
			return builder.build();
		} catch (IOException e)
		{ 
			logger.error("deserialize request", e);
		} 
		return SenseiSysRequestBPO.SysRequest.getDefaultInstance(); 
	} 
	public static SenseiSystemInfo convert(SenseiSysResultBPO.SysResult res)
	{ 
		try 
9
CodeRank
This code example shows how to use the following methods:close, flush, writeObject

Related ObjectOutputStream close Questions & Answers:

close Method Overview
Closes the stream.
See Code Examples for other Java 8 ObjectOutputStream Methods: