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 .