public static ByteBuf serialize ( final Serializable serializable ) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; ; ObjectOutputStream os = new ObjectOutputStream ( bos ) ; os . writeObject ( serializable ) ; byte [ ] serialized = bos . toByteArray ( ) ; os . close ( ) ; bos . close ( ) ; return Unpooled . buffer ( ) . writeBytes ( serialized ) ; }
Serializes the input into a ByteBuf .