Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 250
Registered: ‎07-18-2008
My Device: Not Specified
Accepted Solution

Parsing XHTML and byte array size limit

Hi,

 

I'd like to parse incoming emails on the device to extract some information. The format of the email is XHTML and I use a sax parser to extract the data (API version 4.2.1).

 

 

InputStream is = new ByteArrayInputStream(xhtml.getBytes(encoding));
_document = docBuilder.parse(is);

 

It works quite well but it seems there's a size limit on byte arrays (max count = 1999) because I got a "unexpected end of file exception" when my string is too long.

 

Does anyone know how to overcome this size limit?

 

Regards,

 

Pierre

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Parsing XHTML and byte array size limit

There's no such limit on byte array lengths. What's coming back from xhtml.getBytes(encoding)? Even without knowing what class of object xhtml is, my guess is that that's truncated somehow. (If it's a String, perhaps it doesn't have all the XHTML in it. Have you checked this?)




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Parsing XHTML and byte array size limit

By default, I think just the first 2K worth of data associated with an email is delivered to the device.  You need to ask for more to get the rest I believe.  Could that be the problem?  Have a look in the KnowledgeBase for articles about this, I do seem to remember seeing one that addressed this and described how to get the remaining data. 

Highlighted
Developer
Posts: 250
Registered: ‎07-18-2008
My Device: Not Specified

Re: Parsing XHTML and byte array size limit

That's right, I forgot this 2k limit for the email body!

 

Anyway, I'm supposed to read the content from the HTML file attached to the email but since the simulators do not support attachments I stored the HTML in the email body.

 

Thanks to both of you for your help.