【发布时间】:2015-02-15 10:44:08
【问题描述】:
与问题 byte array to Int Array 相关,但是我想将每个字节转换为 int,而不是每个 4 字节。
有没有比这更好/更清洁的方法:
protected static int[] bufferToIntArray(ByteBuffer buffer) {
byte[] byteArray = new byte[buffer.capacity()];
buffer.get(byteArray);
int[] intArray = new int[byteArray.length];
for (int i = 0; i < byteArray.length; i++) {
intArray[i] = byteArray[i];
}
return intArray;
}
【问题讨论】: