reverse a byte array in place WARNING the parameter array is altered and
returned.

@param data
ori data
@return reverse data
966062
public static byte[] reverse(byte[] data) {
        for (int i = 0, j = data.length - 1; i < data.length / 2; i++, j--) {
            data[i] ^= data[j];
            data[j] ^= data[i];
            data[i] ^= data[j];
        }
        return data;
    }
1248090
public static void reverse(byte[] bytes) {
    for (int i = 0; i < bytes.length / 2; i++) {
      byte temp = bytes[i];
      bytes[i] = bytes[bytes.length - 1 - i];
      bytes[bytes.length - 1 - i] = temp;
    }
  }
23913
public static final long getLong(byte[] data, int offset)
   {
      long result = 0;
      int i = offset;
      for (int shiftBy = 0; shiftBy < 64; shiftBy += 8)
      {
         result |= ((long) (data[i] & 0xff)) << shiftBy;
         ++i;
      }
      return result;
   }
62174
public static byte[] calculate(final Data[] data) throws IOException {
        int bitSize = 0;
        for (final Data target : data) {
            bitSize += target.numOfBits;
        }
        int pos = 0;
        final FastBitSet bitSet = new FastBitSet(bitSize);
        for (final Data target : data) {
            int count = 0;
            final byte[] bytes = calculate(target);
            for (final byte b : bytes) {
                byte bits = b;
                for (int j = 0; j < 8; j++) {
                    bitSet.set(pos, (bits & 0x1) == 0x1);
                    pos++;
                    count++;
                    if (count >= target.numOfBits) {
                        break;
                    }
                    bits >>= 1;
                }
            }
        }
        return bitSet.toByteArray();
    }
444114
public static byte[] hexStringToBytes(String data) {
        if (data == null)
            return EMPTY_BYTE_ARRAY;
        if (data.startsWith("0x"))
            data = data.substring(2);
        return Hex.decode(data);
    }
418278
@Nonnull
    public static SessionValidityInfo decode( @Nonnull final byte[] data ) {
        int idx = 0;
        final int maxInactiveInterval = (int) decodeNum( data, idx, 4 );
        final long lastAccessedTime = decodeNum( data, idx += 4, 8 );
        final long thisAccessedTime = decodeNum( data, idx += 8, 8 );
        return new SessionValidityInfo( maxInactiveInterval, lastAccessedTime, thisAccessedTime );
    }
453538
public static double byteArrayToDoubleLE( byte[] data ) {
        ByteBuffer buffer = ByteBuffer.wrap(data);
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        return buffer.getDouble();
    }
1032899
public static void reverse (byte[] values, int offset, int length)
    {
        int aidx = offset;
        int bidx = offset + length - 1;
        while (bidx > aidx) {
            byte value = values[aidx];
            values[aidx] = values[bidx];
            values[bidx] = value;
            aidx++;
            bidx--;
        }
    }
467781
@SuppressWarnings("unchecked")
    public BaseBo fromByteArray(byte[] data) {
        Map<String, Object> dataMap = null;
        try {
            dataMap = data != null ? SerializationUtils.fromByteArray(data, Map.class) : null;
        } catch (Exception e) {
            dataMap = null;
        }
        return fromMap(dataMap);
    }
930309
public static byte[] reverseByteArray(byte[] inputByteArray) {
	byte[] result=new byte[inputByteArray.length];
	for (int i=inputByteArray.length-1;i>=0;i--) {
		result[result.length-1-i]=inputByteArray[i];
	}
	return result;
}
407987
public static byte[] encode(byte[] data)
	{
		int sourceChunks = data.length / 3;
		int len = (data.length + 2) / 3 * 4;
		byte[] result = new byte[len];
		int extraBytes = data.length - sourceChunks * 3;
		// Each 4 bytes of input (encoded) we end up with 3 bytes of output
		int dataIndex = 0;
		int resultIndex = 0;
		int allBits = 0;
		for (int i = 0; i < sourceChunks; i++)
		{
			allBits = 0;
			// Loop 3 times gathering input bits (3 * 8 = 24)
			for (int j = 0; j < 3; j++)
			{
				allBits = allBits << 8 | data[dataIndex++] & 0xff;
			}
			// Loop 4 times generating output bits (4 * 6 = 24)
			for (int j = resultIndex + 3; j >= resultIndex; j--)
			{
				result[j] = (byte) digits[allBits & 0x3f]; // Bottom
				// 6
				// bits
				allBits = allBits >>> 6;
			}
			resultIndex += 4; // processed 4 result bytes
		}
		// Now we do the extra bytes in case the original (non-encoded) data
		// is not multiple of 4 bytes
		switch (extraBytes)
		{
			case 1:
				allBits = data[dataIndex++]; // actual byte
				allBits = allBits << 8; // 8 bits of zeroes
				allBits = allBits << 8; // 8 bits of zeroes
				// Loop 4 times generating output bits (4 * 6 = 24)
				for (int j = resultIndex + 3; j >= resultIndex; j--)
				{
					result[j] = (byte) digits[allBits & 0x3f]; // Bottom
					// 6
					// bits
					allBits = allBits >>> 6;
				}
				// 2 pad tags
				result[result.length - 1] = equalSign;
				result[result.length - 2] = equalSign;
				break;
			case 2:
				allBits = data[dataIndex++]; // actual byte
				allBits = allBits << 8 | data[dataIndex++] & 0xff; // actual
				// byte
				allBits = allBits << 8; // 8 bits of zeroes
				// Loop 4 times generating output bits (4 * 6 = 24)
				for (int j = resultIndex + 3; j >= resultIndex; j--)
				{
					result[j] = (byte) digits[allBits & 0x3f]; // Bottom
					// 6
					// bits
					allBits = allBits >>> 6;
				}
				// 1 pad tag
				result[result.length - 1] = equalSign;
				break;
		}
		return result;
	}
917101
public static byte[] newByteArray(byte[] data) {
        if (data == null) {
            throw new IllegalArgumentException("Data you want to copy are backed by null object.");
        }
        byte[] buffer = new byte[data.length];
        System.arraycopy(data, 0, buffer, 0, data.length);
        return buffer;
    }
100775
public static int readLen(byte[] data) {
        if (data.length < Datagram.HEADER_LEN) {
            log.warn("要读取长度的数据报报头不完整");
            return -1;
        } else {
            return convert(data, Datagram.LEN_OFFSET);
        }
    }
1260801
public static byte[] encodeBZ(String data) {
    try {
      byte[] bytes = encodeBZ(data.getBytes("UTF-8"));
      //assert(data.equals(decodeBZ(bytes)));
      return bytes;
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
236820
protected String getString(byte[] data, int offset) {
        if (offset < 0) {
            return "";
        }

        int i = offset;
        while (data[i++] != 0x00) {
            ;
        }
        return getString(data, offset, i - offset - 1);
    }
882999
public Object deserialize(String data) {
		if ((data == null) || (data.length() == 0)) {
			return null;
		}
		ObjectInputStream ois = null;
		ByteArrayInputStream bis = null;
		try {
			bis = new ByteArrayInputStream(Base64.decodeBase64(data.getBytes()));
			ois = new ObjectInputStream(bis);
			return ois.readObject();
		} catch (ClassNotFoundException e) {
			LOGGER.error("Can't deserialize data from Base64", e);
			throw new IllegalArgumentException(e);
		} catch (IOException e) {
			LOGGER.error("Can't deserialize data from Base64", e);
			throw new IllegalArgumentException(e);
		} catch (Exception e) {
			LOGGER.error("Can't deserialize data from Base64", e);
			throw new IllegalArgumentException(e);
		} finally {
			try {
				if (ois != null) {
					ois.close();
				}
			} catch (Exception e) {
				LOGGER.error("Can't close ObjetInputStream used for deserialize data from Base64", e);
			}
		}
	}
1136340
static public String getHexDump(byte[] data) {
        return (null == data) ? null : getHexDump(data, data.length);
    }