Breaking News

android – Why am I getting an ArraIndexOutOfBoundException?-Exceptionshub

Questions:

I am trying to copy an byte array (fileData), which I read from a file, into another byte array (subdata) (below the code):

                ByteBuffer inputBuffer = decoderInputBuffers[intBufIndex];
                int limit = inputBuffer.capacity();
                int pos = frameIndex * limit;
                byte[] subData = new byte[limit];

                System.arraycopy(fileData, pos, subData, 0, subData.length);

My question is why I am gettng this error?

java.lang.ArrayIndexOutOfBoundsException: src.length=732542 srcPos=0 dst.length=1572864 dstPos=0 length=1572864

How ist that even possible since I say explicitly say what the size of the array should be.

How to&Answers:

If you look at the docs (which you have linknd in comments) it says that the last parameter of the function is:

length − This is the number of array elements to be copied.

so if you look closely you are trying to copy 1572864 from an array of 732542 and that’s why you are getting the exception

About rankhawks

Check Also

jQuery offline slideshow on Android-Exceptionshub

(function($){ $.fn.chocolate = function(args) { // Default Options var options = $.extend({ interval : 1000, …

c# – How to handle mocking (Rhino Mock) and unity container in different unit test classes?-Exceptionshub

Questions: I am working on a large desktop application. The application communicates with number of …

javascript – Actualize Database Data with Functions Cloud-Exceptionshub

Questions: I am developing an Android application and I have a problem that I cannot …

valgrind for Android devices (Crystax). configure: error: C compiler cannot create executables-Exceptionshub

Questions: Using and adapting the script(https://gist.github.com/smits/27060b310546ca6f76568f24838118c3) I get and error ” C compiler cannot create …

c# – Save position of Snake and Detect Collison with it self. Whats wrong?-Exceptionshub

Questions: using System; using System.Windows.Forms; using System.Collections.Generic; using System.Drawing; using OpenTK; using OpenTK.Graphics.OpenGL; using OpenTK.Graphics; …

Leave a Reply

Your email address will not be published. Required fields are marked *