0

I have a 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]

now i want this [1,1,2,1,3,3,3,2,0,0,0,0,0,0,0] into some int[ ] series ie:

 int[ ] series ={1,1,2,1,3,3,3,2,0,0,0,0,0,0,0}

So how this can be done??

I used

 int[]intArray = new int[1024];
 intArray = ByteBuffer.wrap(arrayOfByte).asIntBuffer().array()

but getting exception as below:

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)
Kiran
  • 3,095
  • 5
  • 23
  • 38

1 Answers1

1

If that doesn't work, try hard-coding it:

int[] intArray = new int[arrayOfByte.length];
for(int i = 0; i < arrayOfByte.length; i++) intArray[i] = (int)arrayOfByte[i];