IndexOutOfBoundsException e

Wasup y'all

My problem is, I have a class (DecodingClassLoader) that calls a method (readStreamToBuffer(InputStream is)) from another class (FileUtiities). Below is the line in the DecodingClassLoader class

classBytes = FileUtilities.readStreamToBuffer( is );

Now, at runtime, when i input the filename on which readStreamToBuffer will act, everything goes well. An attempt to repeat this process without first exiting and restarting the application results in a IndexOutOfBounds exception.

Below is the code segment within the FileUtilities class that generates this exception

while (( bytesReadInPass = is.read( retVal , totalBytesRead , BUFFER_EXTENT_SIZE ) ) >= BUFFER_EXTENT_SIZE){

totalBytesRead += bytesReadInPass;

// Expand the buffer by BUFFER_EXTENT_SIZE

byte[] tmpBuf =newbyte[ retVal.length + BUFFER_EXTENT_SIZE ];

System.arraycopy( retVal , 0 , tmpBuf , 0 , retVal.length );

retVal = tmpBuf;

}

please help!

[1230 byte] By [sbankyba] at [2007-10-2 17:00:39]
# 1

Probably one of these two conditions stated in the API for the arraycopy method are not being met:

srcPos+length is greater than src.length, the length of the source array.

destPos+length is greater than dest.length, the length of the destination array.

Print values of the variables to see exactly where the problem is. The error should have given a line nbr and the index value that failed.

ChuckBinga at 2007-7-13 18:14:12 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
thanks buddy but it wasn't that.figured it out though. it's the totalBytesRead variable. Had to reset it to 0
bankolea at 2007-7-13 18:14:12 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...