public byte[] toByteArray() {
        try {
            ByteArrayOutputStream bout = new ByteArrayOutputStream(size());
            pipe(bout);
            return bout.toByteArray();
        } catch (IOException ioe) {
            throw new RuntimeException("should be impossible", ioe);
        }
    }
public byte[] toByteArray() {
        try {
            ByteArrayOutputStream bout = new ByteArrayOutputStream(size());
            pipe(bout);
            return bout.toByteArray();
        } catch (IOException ioe) {
            throw new RuntimeException("should be impossible", ioe);
        }
    }
public byte [ ] toByteArray ( ) { try { ByteArrayOutputStream bout = new ByteArrayOutputStream ( size ( ) ) ; pipe ( bout ) ; return bout . toByteArray ( ) ; } catch ( IOException ioe ) { throw new RuntimeException ( "should be impossible" , ioe ) ; } }
Gets a copy of the buffered bytes.

@return the byte array
@see org.bson.io.OutputBuffer#pipe(java.io.OutputStream)
Gets a copy of the buffered bytes .