我有一个ArrayOfByte
Log.d(TAG, "arrayOfByte :"+arrayOfByte); // it will display arrayOfByte :[B@2b052c60
Log.d(TAG, "arrayOfByte :"+ Arrays.toString(arrayOfByte)); //it displays arrayOfByte :[1,1,2,1,3,3,3,2,0,0,0,0,0,0,0]
现在我想把它[1,1,2,1,3,3,3,2,0,0,0,0,0,0,0]
变成一些int[ ] series
即:
int[ ] series ={1,1,2,1,3,3,3,2,0,0,0,0,0,0,0}
那么如何做到这一点呢?
我用了
int[]intArray = new int[1024];
intArray = ByteBuffer.wrap(arrayOfByte).asIntBuffer().array()
但得到如下异常:
04-24 11:32:34.750: E/AndroidRuntime(4927): FATAL EXCEPTION: Thread-10
04-24 11:32:34.750: E/AndroidRuntime(4927): java.lang.UnsupportedOperationException
04-24 11:32:34.750: E/AndroidRuntime(4927): at java.nio.IntToByteBufferAdapter.protectedArray(IntToByteBufferAdapter.java:169)
04-24 11:32:34.750: E/AndroidRuntime(4927): at java.nio.IntBuffer.array(IntBuffer.java:109)