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

Posts: 21
Registered: ‎08-31-2011
My Device: Touch 4.5
My Carrier: Airtel

IOException in reading InputStream

hello All,


In the following code the inputstrean is opened properly, but when I try to read it, I get IOException.


But this is not the case always, sometimes the inputStream is read perfectly without exception. I dont understant why does this happen.!!


InputStream inputStream = null;

   try {

inputStream = httpConn2.openInputStream();


catch (IOException e) {


System.out.println("mCIError ServerConnManager: exception opening the stream");

           byte[] data = new byte[4096];           int len = 0;           StringBuffer raw = new StringBuffer("");
           try {                   

while((len = inputStream.read(data)) != -1)


raw.append(new String(data, 0,len));


System.out.println("raw: " + raw);


} catch (IOException e) {

e.printStackTrace();System.out.println("mCIError ServerConnManager: error reading from inputstream");


Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: IOException in reading InputStream

Hello jaydeepw,


Can you confirm the returned values of IOException.toString() and IOException.getMessage() for your e IOException Object? This may provide a little more information as to why the IOException is being thrown in the first place.


Erik Oros

BlackBerry Development Advisor

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.