Class ByteArrayUtil


  • public class ByteArrayUtil
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static byte[] EMPTY_BYTE_ARRAY  
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteArrayUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] bytes​(byte b)  
      static byte[] bytes​(double v)  
      static byte[] bytes​(float v)  
      static byte[] bytes​(int v)  
      static byte[] bytes​(long v)  
      static byte[] bytes​(short v)  
      static byte[] bytes​(java.lang.String v)  
      static byte[] bytes​(java.lang.String v, java.nio.charset.Charset charset)  
      static java.lang.String bytesToHex​(byte[] bytes)  
      static int compareUnsigned​(byte[] o1, byte[] o2)  
      static int compareUnsigned​(byte[] o1, int off1, byte[] o2, int off2, int len)  
      static void copyBytes​(byte[] src, int srcPos, byte[] dst, int dstPos, int length)  
      static void copyBytes​(byte[] src, int srcPos, java.nio.ByteBuffer dst, int dstPos, int length)  
      static boolean getBoolean​(byte[] b, int off)  
      static char getChar​(byte[] b, int off)  
      static double getDouble​(byte[] b, int off)  
      static float getFloat​(byte[] b, int off)  
      static int getInt​(byte[] b)  
      static int getInt​(byte[] b, int off)  
      static long getLong​(byte[] b)  
      static long getLong​(byte[] b, int off)  
      static short getShort​(byte[] b, int off)  
      static int getUnsignedShort​(byte[] b, int off)  
      static byte[] hexToBytes​(java.lang.String hex)  
      static void putBoolean​(byte[] b, int off, boolean val)  
      static void putChar​(byte[] b, int off, char val)  
      static void putDouble​(byte[] b, int off, double val)  
      static void putFloat​(byte[] b, int off, float val)  
      static void putInt​(byte[] b, int off, int val)  
      static void putLong​(byte[] b, int off, long val)  
      static void putShort​(byte[] b, int off, short val)  
      static byte[] readWithLength​(java.io.DataInput in)  
      static byte[] readWithShortLength​(java.io.DataInput in)  
      static byte[] readWithVIntLength​(DataInputPlus in)  
      static int serializedSizeWithVIntLength​(byte[] bytes)  
      static java.lang.String string​(byte[] bytes)  
      static java.lang.String string​(byte[] buffer, java.nio.charset.Charset charset)  
      static void writeWithLength​(byte[] bytes, java.io.DataOutput out)  
      static void writeWithShortLength​(byte[] buffer, java.io.DataOutput out)  
      static void writeWithVIntLength​(byte[] bytes, DataOutputPlus out)  
      • Methods inherited from class java.lang.Object

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

      • EMPTY_BYTE_ARRAY

        public static final byte[] EMPTY_BYTE_ARRAY
    • Constructor Detail

      • ByteArrayUtil

        public ByteArrayUtil()
    • Method Detail

      • compareUnsigned

        public static int compareUnsigned​(byte[] o1,
                                          byte[] o2)
      • compareUnsigned

        public static int compareUnsigned​(byte[] o1,
                                          int off1,
                                          byte[] o2,
                                          int off2,
                                          int len)
      • bytes

        public static byte[] bytes​(byte b)
      • bytes

        public static byte[] bytes​(int v)
      • bytes

        public static byte[] bytes​(long v)
      • bytes

        public static byte[] bytes​(short v)
      • bytes

        public static byte[] bytes​(float v)
      • bytes

        public static byte[] bytes​(double v)
      • bytes

        public static byte[] bytes​(java.lang.String v)
      • bytes

        public static byte[] bytes​(java.lang.String v,
                                   java.nio.charset.Charset charset)
      • getBoolean

        public static boolean getBoolean​(byte[] b,
                                         int off)
      • getChar

        public static char getChar​(byte[] b,
                                   int off)
      • getShort

        public static short getShort​(byte[] b,
                                     int off)
      • getUnsignedShort

        public static int getUnsignedShort​(byte[] b,
                                           int off)
      • getInt

        public static int getInt​(byte[] b,
                                 int off)
      • getInt

        public static int getInt​(byte[] b)
      • getFloat

        public static float getFloat​(byte[] b,
                                     int off)
      • getLong

        public static long getLong​(byte[] b)
      • getLong

        public static long getLong​(byte[] b,
                                   int off)
      • getDouble

        public static double getDouble​(byte[] b,
                                       int off)
      • putBoolean

        public static void putBoolean​(byte[] b,
                                      int off,
                                      boolean val)
      • putChar

        public static void putChar​(byte[] b,
                                   int off,
                                   char val)
      • putShort

        public static void putShort​(byte[] b,
                                    int off,
                                    short val)
      • putInt

        public static void putInt​(byte[] b,
                                  int off,
                                  int val)
      • putFloat

        public static void putFloat​(byte[] b,
                                    int off,
                                    float val)
      • putLong

        public static void putLong​(byte[] b,
                                   int off,
                                   long val)
      • putDouble

        public static void putDouble​(byte[] b,
                                     int off,
                                     double val)
      • bytesToHex

        public static java.lang.String bytesToHex​(byte[] bytes)
      • hexToBytes

        public static byte[] hexToBytes​(java.lang.String hex)
      • string

        public static java.lang.String string​(byte[] bytes)
                                       throws java.nio.charset.CharacterCodingException
        Throws:
        java.nio.charset.CharacterCodingException
      • string

        public static java.lang.String string​(byte[] buffer,
                                              java.nio.charset.Charset charset)
                                       throws java.nio.charset.CharacterCodingException
        Throws:
        java.nio.charset.CharacterCodingException
      • writeWithLength

        public static void writeWithLength​(byte[] bytes,
                                           java.io.DataOutput out)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeWithShortLength

        public static void writeWithShortLength​(byte[] buffer,
                                                java.io.DataOutput out)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • writeWithVIntLength

        public static void writeWithVIntLength​(byte[] bytes,
                                               DataOutputPlus out)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • serializedSizeWithVIntLength

        public static int serializedSizeWithVIntLength​(byte[] bytes)
      • readWithLength

        public static byte[] readWithLength​(java.io.DataInput in)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readWithShortLength

        public static byte[] readWithShortLength​(java.io.DataInput in)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readWithVIntLength

        public static byte[] readWithVIntLength​(DataInputPlus in)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • copyBytes

        public static void copyBytes​(byte[] src,
                                     int srcPos,
                                     byte[] dst,
                                     int dstPos,
                                     int length)
      • copyBytes

        public static void copyBytes​(byte[] src,
                                     int srcPos,
                                     java.nio.ByteBuffer dst,
                                     int dstPos,
                                     int length)