类 Bytes


  • public class Bytes
    extends Object
    CodecUtils.
    • 方法详细资料

      • copyOf

        public static byte[] copyOf(byte[] src,
                                    int length)
        byte array copy.
        参数:
        src - src.
        length - new length.
        返回:
        new byte array.
      • short2bytes

        public static byte[] short2bytes(short v)
        to byte array.
        参数:
        v - value.
        返回:
        byte[].
      • short2bytes

        public static void short2bytes(short v,
                                       byte[] b)
        to byte array.
        参数:
        v - value.
        b - byte array.
      • short2bytes

        public static void short2bytes(short v,
                                       byte[] b,
                                       int off)
        to byte array.
        参数:
        v - value.
        b - byte array.
      • int2bytes

        public static byte[] int2bytes(int v)
        to byte array.
        参数:
        v - value.
        返回:
        byte[].
      • int2bytes

        public static void int2bytes(int v,
                                     byte[] b)
        to byte array.
        参数:
        v - value.
        b - byte array.
      • int2bytes

        public static void int2bytes(int v,
                                     byte[] b,
                                     int off)
        to byte array.
        参数:
        v - value.
        b - byte array.
        off - array offset.
      • float2bytes

        public static byte[] float2bytes(float v)
        to byte array.
        参数:
        v - value.
        返回:
        byte[].
      • float2bytes

        public static void float2bytes(float v,
                                       byte[] b)
        to byte array.
        参数:
        v - value.
        b - byte array.
      • float2bytes

        public static void float2bytes(float v,
                                       byte[] b,
                                       int off)
        to byte array.
        参数:
        v - value.
        b - byte array.
        off - array offset.
      • long2bytes

        public static byte[] long2bytes(long v)
        to byte array.
        参数:
        v - value.
        返回:
        byte[].
      • long2bytes

        public static void long2bytes(long v,
                                      byte[] b)
        to byte array.
        参数:
        v - value.
        b - byte array.
      • long2bytes

        public static void long2bytes(long v,
                                      byte[] b,
                                      int off)
        to byte array.
        参数:
        v - value.
        b - byte array.
        off - array offset.
      • double2bytes

        public static byte[] double2bytes(double v)
        to byte array.
        参数:
        v - value.
        返回:
        byte[].
      • double2bytes

        public static void double2bytes(double v,
                                        byte[] b)
        to byte array.
        参数:
        v - value.
        b - byte array.
      • double2bytes

        public static void double2bytes(double v,
                                        byte[] b,
                                        int off)
        to byte array.
        参数:
        v - value.
        b - byte array.
        off - array offset.
      • bytes2short

        public static short bytes2short(byte[] b)
        to short.
        参数:
        b - byte array.
        返回:
        short.
      • bytes2short

        public static short bytes2short(byte[] b,
                                        int off)
        to short.
        参数:
        b - byte array.
        off - offset.
        返回:
        short.
      • bytes2int

        public static int bytes2int(byte[] b)
        to int.
        参数:
        b - byte array.
        返回:
        int.
      • bytes2int

        public static int bytes2int(byte[] b,
                                    int off)
        to int.
        参数:
        b - byte array.
        off - offset.
        返回:
        int.
      • bytes2float

        public static float bytes2float(byte[] b)
        to int.
        参数:
        b - byte array.
        返回:
        int.
      • bytes2float

        public static float bytes2float(byte[] b,
                                        int off)
        to int.
        参数:
        b - byte array.
        off - offset.
        返回:
        int.
      • bytes2long

        public static long bytes2long(byte[] b)
        to long.
        参数:
        b - byte array.
        返回:
        long.
      • bytes2long

        public static long bytes2long(byte[] b,
                                      int off)
        to long.
        参数:
        b - byte array.
        off - offset.
        返回:
        long.
      • bytes2double

        public static double bytes2double(byte[] b)
        to long.
        参数:
        b - byte array.
        返回:
        double.
      • bytes2double

        public static double bytes2double(byte[] b,
                                          int off)
        to long.
        参数:
        b - byte array.
        off - offset.
        返回:
        double.
      • bytes2hex

        public static String bytes2hex(byte[] bs)
        to hex string.
        参数:
        bs - byte array.
        返回:
        hex string.
      • bytes2hex

        public static String bytes2hex(byte[] bs,
                                       int off,
                                       int len)
        to hex string.
        参数:
        bs - byte array.
        off - offset.
        len - length.
        返回:
        hex string.
      • hex2bytes

        public static byte[] hex2bytes(String str)
        from hex string.
        参数:
        str - hex string.
        返回:
        byte array.
      • hex2bytes

        public static byte[] hex2bytes(String str,
                                       int off,
                                       int len)
        from hex string.
        参数:
        str - hex string.
        off - offset.
        len - length.
        返回:
        byte array.
      • bytes2base64

        public static String bytes2base64(byte[] b)
        to base64 string.
        参数:
        b - byte array.
        返回:
        base64 string.
      • bytes2base64

        public static String bytes2base64(byte[] b,
                                          int offset,
                                          int length)
        to base64 string.
        参数:
        b - byte array.
        返回:
        base64 string.
      • bytes2base64

        public static String bytes2base64(byte[] b,
                                          String code)
        to base64 string.
        参数:
        b - byte array.
        code - base64 code string(0-63 is base64 char,64 is pad char).
        返回:
        base64 string.
      • bytes2base64

        public static String bytes2base64(byte[] b,
                                          int offset,
                                          int length,
                                          String code)
        to base64 string.
        参数:
        b - byte array.
        code - base64 code string(0-63 is base64 char,64 is pad char).
        返回:
        base64 string.
      • bytes2base64

        public static String bytes2base64(byte[] b,
                                          char[] code)
        to base64 string.
        参数:
        b - byte array.
        code - base64 code(0-63 is base64 char,64 is pad char).
        返回:
        base64 string.
      • bytes2base64

        public static String bytes2base64(byte[] bs,
                                          int off,
                                          int len,
                                          char[] code)
        to base64 string.
        参数:
        bs - byte array.
        off - offset.
        len - length.
        code - base64 code(0-63 is base64 char,64 is pad char).
        返回:
        base64 string.
      • base642bytes

        public static byte[] base642bytes(String str)
        from base64 string.
        参数:
        str - base64 string.
        返回:
        byte array.
      • base642bytes

        public static byte[] base642bytes(String str,
                                          int offset,
                                          int length)
        from base64 string.
        参数:
        str - base64 string.
        offset - offset.
        length - length.
        返回:
        byte array.
      • base642bytes

        public static byte[] base642bytes(String str,
                                          String code)
        from base64 string.
        参数:
        str - base64 string.
        code - base64 code(0-63 is base64 char,64 is pad char).
        返回:
        byte array.
      • base642bytes

        public static byte[] base642bytes(String str,
                                          int off,
                                          int len,
                                          String code)
        from base64 string.
        参数:
        str - base64 string.
        off - offset.
        len - length.
        code - base64 code(0-63 is base64 char,64 is pad char).
        返回:
        byte array.
      • base642bytes

        public static byte[] base642bytes(String str,
                                          char[] code)
        from base64 string.
        参数:
        str - base64 string.
        code - base64 code(0-63 is base64 char,64 is pad char).
        返回:
        byte array.
      • base642bytes

        public static byte[] base642bytes(String str,
                                          int off,
                                          int len,
                                          char[] code)
        from base64 string.
        参数:
        str - base64 string.
        off - offset.
        len - length.
        code - base64 code(0-63 is base64 char,64 is pad char).
        返回:
        byte array.
      • zip

        public static byte[] zip(byte[] bytes)
                          throws IOException
        zip.
        参数:
        bytes - source.
        返回:
        compressed byte array.
        抛出:
        IOException
      • unzip

        public static byte[] unzip(byte[] bytes)
                            throws IOException
        unzip.
        参数:
        bytes - compressed byte array.
        返回:
        byte uncompressed array.
        抛出:
        IOException
      • getMD5

        public static byte[] getMD5(String str)
        get md5.
        参数:
        str - input string.
        返回:
        MD5 byte array.
      • getMD5

        public static byte[] getMD5(byte[] source)
        get md5.
        参数:
        source - byte array source.
        返回:
        MD5 byte array.
      • getMD5

        public static byte[] getMD5(File file)
                             throws IOException
        get md5.
        参数:
        file - file source.
        返回:
        MD5 byte array.
        抛出:
        IOException