Code example for ObjectOutputStream

Methods: closeflushwriteObject

0
        int startIdx = out.writerIndex();
 
        ByteBufOutputStream bout = new ByteBufOutputStream(out);
        bout.write(LENGTH_PLACEHOLDER);
        ObjectOutputStream oout = new CompactObjectOutputStream(bout);
        oout.writeObject(msg);
        oout.flush();
        oout.close();
 
        int endIdx = out.writerIndex();
 
        out.setInt(startIdx, endIdx - startIdx - 4);
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE