public static List<Byte> bytesToList(byte[] bytes) {
return Bytes.asList(bytes);
}
/**
* list转字节组
*
* @param list list
* @return byte[]
*/
public static byte[] listToBytes(List<Byte> list) {
return Bytes.toArray(list);
}
/**
* 截取bytes
*
* @param bytes 字节组
* @param from 起始位
* @param to 结束位
* @return bytes
*/
public static byte[] subBytes(byte[] bytes, int from, int to) {
return Arrays.copyOfRange(bytes, from, to);
}
public static short bytes2Short(byte[] bytes) {
short result=0;
int len = bytes.length;
for(int i=len-1;i>=0; i--){
result |= (short)(i==0 ? bytes[i]:(bytes[i] & 0xff)) << ((len-1-i)<<3);
}
return result;
}