Class ByteUtil


  • public class ByteUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] bytes​(java.lang.String str)
      Convert a String to a UTF-8 byte array.
      static int memcmp​(java.nio.ByteBuffer x, java.nio.ByteBuffer y, int count)
      Compares the first count bytes of two areas of memory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteUtil

        public ByteUtil()
    • Method Detail

      • bytes

        public static byte[] bytes​(java.lang.String str)
        Convert a String to a UTF-8 byte array.
        Parameters:
        str - the string
        Returns:
        the byte array.
      • memcmp

        public static int memcmp​(java.nio.ByteBuffer x,
                                 java.nio.ByteBuffer y,
                                 int count)
        Compares the first count bytes of two areas of memory. Returns zero if they are the same, a value less than zero if x is lexically less than y, or a value greater than zero if x is lexically greater than y. Note that lexical order is determined as if comparing unsigned char arrays. Similar to memcmp.c.
        Parameters:
        x - the first value to compare with
        y - the second value to compare against
        count - the number of bytes to compare
        Returns:
        the result of the comparison