bson/src/main/org/bson/types/ObjectId.java
public byte[] toByteArray() {
        ByteBuffer buffer = ByteBuffer.allocate(OBJECT_ID_LENGTH);
        putToByteBuffer(buffer);
        return buffer.array();  // using .allocate ensures there is a backing array that can be returned
    }
public byte[] toByteArray() {
        ByteBuffer buffer = ByteBuffer.allocate(OBJECT_ID_LENGTH);
        putToByteBuffer(buffer);
        return buffer.array();  // using .allocate ensures there is a backing array that can be returned
    }
public byte [ ] toByteArray ( ) { ByteBuffer buffer = ByteBuffer . allocate ( OBJECT_ID_LENGTH ) ; putToByteBuffer ( buffer ) ; return buffer . array ( ) ; // using .allocate ensures there is a backing array that can be returned }
Convert to a byte array.  Note that the numbers are stored in big-endian order.

@return the byte array
Convert to a byte array . Note that the numbers are stored in big - endian order .