question: public static void putObject ( final ByteBuffer buffer , Serializable o ) { try ( ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ) { try ( ObjectOutput oout = new ObjectOutputStream ( bos ) ) { oout . writeObject ( o ) ; byte [ ] laneBytes = bos . toByteArray ( ) ; buffer . putInt ( laneBytes . length ) ; for ( int i = 0 ; i < laneBytes . length ; i ++ ) { buffer . put ( laneBytes [ i ] ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } }
target:  Writes the given Serializable to the ByteBuffer. First writes the length of the Serializable as int, then writes the single bytes of the serialized object. The ByteBuffer's position is incremented according to the length of the Serializable.