Hi Theo,
I have edited your original post to put the code between [code] and [/code]
UBB tags. Doing this ensures that indenting is preserved, which makes the code easier to read.
When you are writing your post, there are a number of buttons just below the edit pane, which will insert the tags for you, so you don't have to remember what they are.
If you would like to edit your original post so that you can see what I have done, you can click on the
![]()
button that is just above
your post.
There is certainly no problem with posting stack traces, and it can be very useful to do so.
Usually you can read stack traces from the top down until you see a method that you recognise as one of
your methods. In the stack trace you provided, the first two methods are from the Java API, so we can ignore them. The third line is one of your methods:
This then identifies exactly where you are referencing an out of bounds exception. It is in the readRecord method, at line 226 of the DataHelper.java file.
This is almost certainly the line:
The problem is with the second parameter.
Short answer - you probably don't need to use this particular method. You will probably find that read(byte[]) will give you the
desired result. Or even better - readFully(byte[]).
Long answer - the offset in the second parameter is not the offset into the file, but the offset into the array. So you are exceeding the size of the array.
The confusing part is that the API reads (IMHO) as though it should be the offset into the file. But here is a simple program to
test this:
And when I run it:
So you see what it is doing now?
Regards, Andrew