将字节转换成十六进制字符串
@param bytes 数据
@param offset 起始位置
@param length 从起始位置开始的长度
@return
333580
public static String SimplePrettyHexDump(byte bytes[], int offset, int length)
    	{
    		ByteArrayOutputStream bos = new ByteArrayOutputStream();
    		PrintStream ps = new PrintStream(bos);
    		int rows = length / 16;//打印的行数
    		int ac = length % 16;//剩余的字节数
    		for (int i = 0; i < rows; ++i)
    			ps.printf("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", //
    					bytes[offset + (16 * i) + 0], //
    					bytes[offset + (16 * i) + 1], //
    					bytes[offset + (16 * i) + 2], //
    					bytes[offset + (16 * i) + 3], //
    					bytes[offset + (16 * i) + 4], //
    					bytes[offset + (16 * i) + 5], //
    					bytes[offset + (16 * i) + 6], //
    					bytes[offset + (16 * i) + 7], //
    					bytes[offset + (16 * i) + 8], //
    					bytes[offset + (16 * i) + 9], //
    					bytes[offset + (16 * i) + 10], //
    					bytes[offset + (16 * i) + 11], //
    					bytes[offset + (16 * i) + 12], //
    					bytes[offset + (16 * i) + 13], //
    					bytes[offset + (16 * i) + 14], //
    					bytes[offset + (16 * i) + 15], //
    					byteToChar(bytes[offset + (16 * i) + 0]), //
    					byteToChar(bytes[offset + (16 * i) + 1]), //
    					byteToChar(bytes[offset + (16 * i) + 2]), //
    					byteToChar(bytes[offset + (16 * i) + 3]), //
    					byteToChar(bytes[offset + (16 * i) + 4]), //
    					byteToChar(bytes[offset + (16 * i) + 5]), //
    					byteToChar(bytes[offset + (16 * i) + 6]), //
    					byteToChar(bytes[offset + (16 * i) + 7]), //
    					byteToChar(bytes[offset + (16 * i) + 8]), //
    					byteToChar(bytes[offset + (16 * i) + 9]), //
    					byteToChar(bytes[offset + (16 * i) + 10]), //
    					byteToChar(bytes[offset + (16 * i) + 11]), //
    					byteToChar(bytes[offset + (16 * i) + 12]), //
    					byteToChar(bytes[offset + (16 * i) + 13]), //
    					byteToChar(bytes[offset + (16 * i) + 14]), //
    					byteToChar(bytes[offset + (16 * i) + 15]));
    		for (int i = 0; i < ac; i++)
    			ps.printf("%02X ", bytes[offset + rows * 16 + i]);
    		for (int i = 0; ac > 0 && i < 16 - ac; i++)
    			ps.printf("%s", "   ");
    		for (int i = 0; i < ac; i++)
    			ps.printf("%c", byteToChar(bytes[offset + rows * 16 + i]));
    		return bos.toString();
    	}
598163
private static void bytesToHex(byte[] bytes, byte[] hex, int offset) {
    final char[] lookup =
        {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

    int i;
    int c;
    int j;
    int pos = offset;

    for (i = 0; i < 16; i++) {
      c = bytes[i] & 0xFF;
      j = c >> 4;
      hex[pos++] = (byte) lookup[j];
      j = (c & 0xF);
      hex[pos++] = (byte) lookup[j];
    }
  }
644762
public static void intToBytes(int value, byte[] bytes, int offset) {
        bytes[offset + 3] = (byte) (value >>> 0);
        bytes[offset + 2] = (byte) (value >>> 8);
        bytes[offset + 1] = (byte) (value >>> 16);
        bytes[offset + 0] = (byte) (value >>> 24);
    }
388946
public static long bytes(byte[] data, int offset, int length) {
        CRC32 crc32 = new CRC32();
        crc32.update(data, offset, length);
        return crc32.getValue();
    }
274814
public static String toHex(byte[] bytes) {
		StringBuilder hexString=new StringBuilder();
		for (int i=0; i<bytes.length; i++) {

			String hex=Integer.toHexString(0xFF & bytes[i]);
			if (hex.length() == 1) {
				hexString.append('0');
			}

			hexString.append(hex);
		}

		return hexString.toString();
	}
826844
public static String hex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = HEXES_SMALL[v >>> 4];
            hexChars[j * 2 + 1] = HEXES_SMALL[v & 0x0F];
        }
        return new String(hexChars);
    }
664442
public static void longToBytes(long value, byte[] bytes, int offset) {
        for (int i = offset + 7; i >= offset; --i) {
            bytes[i] = (byte) value;
            value = value >> 8;
        }
    }
997996
public static long getValue(byte[] bytes, int offset) {
    long value = (bytes[offset + BYTE_3] << BYTE_3_SHIFT) & BYTE_3_MASK;
    value += (bytes[offset + BYTE_2] << BYTE_2_SHIFT) & BYTE_2_MASK;
    value += (bytes[offset + BYTE_1] << BYTE_1_SHIFT) & BYTE_1_MASK;
    value += (bytes[offset] & BYTE_MASK);
    return value;
  }
1184946
public static int bitLength (byte[] bytes) {
        Objects.requireNonNull(bytes, Required.BYTES.toString());
        int byteLength = bytes.length;
        
        int length = 0;
        if (byteLength <= MAX_BYTE_LENGTH && byteLength > 0) {
            length = byteLength * BYTES;
        }
        
        return length;
    }
825798
public static int varIntBytesToInt(byte[] bytes, int offset) {

        byte tmp = bytes[offset++];
        if (tmp >= 0) {
            return tmp;
        }
        int result = tmp & 0x7f;
        if ((tmp = bytes[offset++]) >= 0) {
            result |= tmp << 7;
        } else {
            result |= (tmp & 0x7f) << 7;
            if ((tmp = bytes[offset++]) >= 0) {
                result |= tmp << 14;
            } else {
                result |= (tmp & 0x7f) << 14;
                if ((tmp = bytes[offset++]) >= 0) {
                    result |= tmp << 21;
                } else {
                    result |= (tmp & 0x7f) << 21;
                    result |= (tmp = bytes[offset++]) << 28;
                    if (tmp < 0) {
                        // Discard upper 32 bits.
                        for (int i = 0; i < 5; i++) {
                            if (bytes[offset++] >= 0) {
                                return result;
                            }
                        }
                        //Should never happen since we wrote the varint value. If this occurs due to an internal bug
                        //this exception is caught and wrapped further up the chain.
                        throw new IllegalStateException("Varint representation is invalid or exceeds 32-bit value");
                    }
                }
            }
        }
        return result;
    }
993988
public static String encodeHex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = HEX_CHARS[v >>> 4];
            hexChars[j * 2 + 1] = HEX_CHARS[v & 0x0F];
        }
        return new String(hexChars);
    }
724861
public static String encodeHexString(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = hexArray[v >>> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }
1022726
public static String toHexStringPadded(byte[] src, int offset, int length) {
        return toHexStringPadded(new StringBuilder(length << 1), src, offset, length).toString();
    }
1054611
public static String binaryToHex(byte[] data, int offset, int length)
    {
        assert offset < data.length && offset >= 0 : offset + ", " + data.length;
        int end = offset + length;
        assert end <= data.length && end >= 0 : offset + ", " + length + ", " + data.length;

        char[] chars = new char[length*2];
        int j = 0;
        for (int i = offset; i < end; i++) {
            int b = data[i];
            chars[j++] = hexDigit(b >>> 4 & 0xF);
            chars[j++] = hexDigit(b & 0xF);
        }

        return new String(chars);
    }
727622
public static long readUnsignedLong(byte[] bytes, int offset) {
      byte b = bytes[offset++];
      long i = b & 0x7F;
      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
         b = bytes[offset++];
         i |= (b & 0x7FL) << shift;
      }
      return i;
   }
84516
public static final String bytesToHex(byte[] bs, int off, int length) {
		StringBuffer sb = new StringBuffer(length * 2);
		bytesToHexAppend(bs, off, length, sb);
		return sb.toString();
	}
366656
public static final String bytesToHex(byte[] bs, int off, int length) {
        if (bs.length <= off || bs.length < off + length)
            throw new IllegalArgumentException();
        StringBuilder sb = new StringBuilder(length * 2);
        bytesToHexAppend(bs, off, length, sb);
        return sb.toString();
    }