I'm reading a byte[] from a device and trying to interpret it as an integer array in Java with the help of the ByteBuffer class but I'm getting an index out of bounds error. Look here:
byteBuffer.put(bytes); // put the array of bytes into the byteBuffer
System.out.println("the value I want is " + byteBuffer.getInt(16*4)); // gives me the number I want, but I'd rather deal with an integer array like this:
System.out.println("the value I want is " + byteBuffer.asIntBuffer().get(16)); // index out of bounds? Why??
asIntBuffer: The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.