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
Contributor
Posts: 27
Registered: ‎05-30-2011
My Device: Blackberry Torch

Get data from inputstream

Hi all,

 

      I need to get more than 15000 bytes of data from inputstream at a time but, I can receive only 8192 bytes of data from inputstream.  How can i increase inputstream size.

 

     And, I am working in chat application using xmpp server. How can i get one by one response from xmpp. Now i am getting more than 3 response at a time,I used timer to get response.

 

Help me please,

 

 

 

Thank you in advance.

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Get data from inputstream

I am not aware of the xmpp protocol, however I can say I have not heard of any restriction in the BB that will restrict any inputstream to just 8K.  So this issue is either in your code or in the protocol.  My first reaction would be to check the code.  You might find the IOUtilities methods useful for getting all the data from an inputstream, rather than coding your own, if you have done so. 

Contributor
Posts: 27
Registered: ‎05-30-2011
My Device: Blackberry Torch

Re: Get data from inputstream

hi,

 

Thanks for your reply peter_strange.

 

I used the following code.

    

System.out.println("Available Inputstream data : "+is.available());

byte[] data=IOUtilities.streamToBytes(is);

System.out.println(data.length);

String str =newString(data);

System.out.println(str);

 

 

I can get available inputstream data is 8192. But the 2nd line is not executing i.e. I cannot get the bytes length and data. I am developing blackberry bold 9930.

 

 

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Get data from inputstream

available() is a guide, it is not definitive.  So if it says 8192, then you have at least 8192.  If it says 0, then may have nothing, but you might also get something if you do the read.

 

I don't understand this comment "the seond line is not executing".  Either it will complete, or it will throw an exception.  If you never see the output from the

system.out.println(data.length);

then I suspect you are seeing an Exception.  You will have caught this somewhere.  What Exception do you see?  What is the detail message? 

 

Contributor
Posts: 27
Registered: ‎05-30-2011
My Device: Blackberry Torch

Re: Get data from inputstream

Hi peter_strange,

 

 

           My code get stop in this particular line of code

 

                 byte[] data=IOUtilities.streamToBytes(is);

 

        And didn't throw any exception on this line.

 

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Get data from inputstream

Ah, OK.  I thought you were reading an http connection.  I have had a quick look at the xmpp protocol, and it would seem that you open a Stream connection.  As such, the read will not complete on EOF, so IOUtilities is the wrong tool for you.

 

I have not managed to figure out how many bytes you are supposed to read.  Until the end of the message seems the obvious answer which means you will have to parse the input, and keep asking for more until you get to the end. 

 

My quick review suggests that the Blackberry is not a great platform for a client like this because it does not like to have sockets open all the time - these will be closed after 2 minutes of inactivity.  So you might find that you can't actually code this on a BlackBerry. 

 

I would do a search on this forum too.  There seem to be a number of other people who have had problems coding xmpp processing on the BlackBerry.

Contributor
Posts: 27
Registered: ‎05-30-2011
My Device: Blackberry Torch

Re: Get data from inputstream

Ok Thanks for your responses peter_strange.