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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Contributor
Posts: 4
Registered: ‎09-28-2011
My Device: all model
My Carrier: Developper

Obex Bluetooth inputStream 4095 bytes limit



we have tried this code to get a stream from a Bluetooth device, in the onPut function extending ServerRequestHandler:



public int onPut(Operation op)
        // Display information about the data received
            // Read the meta data of a received file
        	fileName = (String) op.getReceivedHeaders().getHeader(HeaderSet.NAME);
            InputStream is = op.openInputStream();
            // Read the content of a received file
            byte b[] = new byte[1024];
            int len = 0;
			String content = "";
            while(is.available() > 0 &&(len = is.read(b)) > 0)// 
            	content += new String(b, 0, len);
        catch(IOException ioe)
        return ResponseCodes.OBEX_HTTP_OK;


If we don't use the "is.available" we get the whole file but we have an error on the Bluetooth device and the application hangs.

If we use "is.available" we have a 4025 bytes file only (we need more) but no error on the device and the application is OK.

How can we get the whole file without error ?

We have seen this question many times on this forum but no answers. 

Any help will be appreciated.


Thank you.

Posts: 36
Registered: ‎01-26-2012
My Device: 9900
My Carrier: T-Mobile DE

Re: Obex Bluetooth inputStream 4095 bytes limit

Couple thoughts:


  1. Suggest you change your buffer to 2048 bytes and don’t change – this gives the best results in our experience (and may solve the hanging issue).
  2. Recommend NOT using the available() AP to determine if the file is complete.
    • Instead use the LENGTH header field (which should be mandatory for OPP) to determine how many bytes are expected, and keep a running tally of the read() calls to know when you’ve read the entire incoming file.
    • ALSO exit the loop if read() returns a negative value
  3. Could also be that the sending side is not following strict OPP protocol and thus wouldn’t connect successfully with BlackBerry 7 over the regular OPP channels. Might be helpfull to trace that
  4. Alternatively, you could simply assume that either read() == -1 OR EOFException means you’ve hit the end of the received data, and exit your loop