public void write( Object object,
                       DataOutput output ) throws IOException {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        write(object, stream);
        stream.flush();
        byte[] bytes = stream.toByteArray();
        output.write(bytes);
    }
public void write ( Object object , DataOutput output ) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; write ( object , stream ) ; stream . flush ( ) ; byte [ ] bytes = stream . toByteArray ( ) ; output . write ( bytes ) ; }
Write to the supplied output the binary BSON representation of the supplied in-memory {@link Document}.

@param object the BSON object or BSON value; may not be null
@param output the output; may not be null
@throws IOException if there was a problem writing to the ObjectOutput