[Biojava-l] Error while reading byte data for creating a Trace.

Richard Holland holland at ebi.ac.uk
Tue Nov 6 10:15:43 UTC 2007

Hash: SHA1

I suspect the byte array itself may contain inaccurate data.

Internally, both the URL and File constructors read the data into a byte
array and then pass it to the same method as is used by the byte[]

So, something must be different between the byte array you have, and the
byte array obtained by reading the file in.

The File constructor uses the following code to read the file:

    byte[] bytes = null;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    FileInputStream fis = new FileInputStream(ABIFile);
    BufferedInputStream bis = new BufferedInputStream(fis);
    int b;
    while ((b = bis.read()) >= 0)
    bis.close(); fis.close(); baos.close();
    bytes = baos.toByteArray();

If the above code produces different results to your byte array when
reading data from the same file as your code, then something has gone
wrong with the construction of your byte array.

Lastly, a full stack trace would help us pinpoint the line that is
breaking, and hopefully provide a hint as to what is wrong with the
contents of the byte array. If you could provide one that would be very


abhi232 at cc.gatech.edu wrote:
> Hi all,
> I am having a byte array which is having the data from an .ab1 file.The
> biojava library provides a class called as ABITrace which takes as input
> either a byte[] array , a file or a url.If i use the later parameters (the
> file or the url )the program works but if I pass the byte array to the
> constructor I get java.lang.arrayIndexOutOfBound.Exception.Is there a
> problem with the ABITrace class or how can I bypass this particular error.
> I am printing the length of the byte array and it comes to 144930...Can
> that cause a problem in my code?
> Thanks in advance.
> Abhinav
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the Biojava-l mailing list