question: public static < ValueT > ByteBuffer toByteBuffer ( ValueT obj ) throws IOException { byte [ ] bytes = null ; ByteArrayOutputStream bos = null ; ObjectOutputStream oos = null ; try { bos = new ByteArrayOutputStream ( ) ; oos = new ObjectOutputStream ( bos ) ; oos . writeObject ( obj ) ; oos . flush ( ) ; bytes = bos . toByteArray ( ) ; } finally { if ( oos != null ) { oos . close ( ) ; } if ( bos != null ) { bos . close ( ) ; } } return ByteBuffer . wrap ( bytes ) ; }
target:  serialize object to a ByteBuffer object.