byte[]转换成short[]
public static 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] << 8 | src[2 * i + 1] & 0xff);
}
return dest;
}
short[]转换成byte[]
public static 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] >> 8);
dest[i * 2 + 1] = (byte) (src[i] >> 0);
}
return dest;
}