[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
-----BEGIN PGP SIGNED MESSAGE-----
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[]
constructor.
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)
{
baos.write(b);
}
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
helpful.
cheers,
Richard
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
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHMD7P4C5LeMEKA/QRAmGIAJ9a/V6nZqMROz3H4u69ECQ+9iTgMgCeNZvr
oe52S3khmTvi5BFCL1W4KHM=
=5JAO
-----END PGP SIGNATURE-----
More information about the Biojava-l
mailing list