Android Java处理两个字节的short转换成byte并放在byte[]
ByteBuffer bbuf = ByteBuffer.allocate(2);
bbuf.putShort(value);
byte[] data = bbuf.array();
ArrayList<Byte> al = new ArrayList<>();
for (int i = data.length - 1; i >= 0; i--) {
al.add(data[i]);
}
byte[] buffer = new byte[al.size()];
for (int i = 0; i <= buffer.length - 1; i++) {
buffer[i] = al.get(i);
}
byte[] buffer1 = new byte[2];
int bufIndex = 0;
for (int i = 0; i < buffer.length; i++) {
buffer1[bufIndex++] = buffer[i];
}