short数组转发byte数组并可实现地位换高位
byte[] tobytes(short[] shorts, boolean bigendian) {
int n = 0;
byte[] bytes = new byte[2*shorts.length];
for (n=0; n < shorts.length; n++) {
byte lsb = shorts[n] & 0xff;
byte msb = (shorts[n] >> 8) & 0xff;
if (bigendian) {
bytes[2*n] = msb;
bytes[2*n+1] = lsb;
} else {
bytes[2*n] = lsb;
bytes[2*n+1] = msb;
}
}
return bytes;
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。