/**
* byte数组转short数组
*
* @param src
* @return
*/
private short[] toShortArray(byte[] src) {
int count = src.length >> 1;
short[] dest = new short[count];
for (int i = 0; i < count; i++) {
dest[i] = (short) ((src[i * 2] & 0xff) | ((src[2 * i + 1] & 0xff) << 8));
}
return dest;
}
/**
* short数组转byte数组
*
* @param src
* @return
*/
private byte[] toByteArray(short[] src) {
int count = src.length;
byte[] dest = new byte[count << 1];
for (int i = 0; i < count; i++) {
dest[i * 2] = (byte) (src[i]);
dest[i * 2 + 1] = (byte) (src[i] >> 8);
}
return dest;
}
Java short[]与byte[]互转
最新推荐文章于 2024-08-05 02:52:04 发布