code: public static ByteBuffer toBuffer(byte array[], int offset, int length) {
          if (array == null)
              return EMPTY_BUFFER;
          return ByteBuffer.wrap(array, offset, length);
      }
docs: Create a new ByteBuffer using the provided byte array.
  
  @param array  the byte array to use.
  @param offset the offset within the byte array to use from
  @param length the length in bytes of the array to use
  @return ByteBuffer with provided byte array, in flush mode