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: 43
Registered: ‎11-30-2011
My Device: Dev Alpha, 8520
My Carrier: Vodafone

Stream Send Error - trying to send a file from BB to BB

I'm sending a file via Bluetooth using the OBEX object push service. I have implemented the good ol' JSR 82 implementation. Here's the part where I actually write the file into the OutputStream.


private void sendFile(String btUrl, FileConnection file)
	ClientSession btSession = null;
		btSession = (ClientSession)Connector.open(btUrl);
		byte[] data = IOUtilities.streamToBytes(file.openInputStream());
		if(btSession.connect(null).getResponseCode() == ResponseCodes.OBEX_HTTP_OK)
			HeaderSet hs = btSession.createHeaderSet();
			hs.setHeader(HeaderSet.NAME, file.getName());
			hs.setHeader(HeaderSet.TYPE, "text/x-vcard");
			hs.setHeader(HeaderSet.LENGTH, new Long(data.length));
			Operation op = btSession.put(hs);
			DataOutputStream btStream = op.openDataOutputStream();
			btStream.write(data, 0, data.length);
			message.addElement("Sent file " + file.getName() + "!");
	catch(IOException e)
		Log.debug("Error !!!! " + e.toString() + e.getMessage());
		message.addElement("Send of" + file.getName() + " failed!");


Now, when sending a file to non-Blackberry devices (Android/Java based/Symbian) this code runs without any issues. But when I try to send it to a Blackberry, btStream.write(data, 0, data.length) throws an IOException, with the detail message saying "Stream Send Error". I've tried all sorts of header arguments and stuff to figure out what the problem is, but it just won't work. I even fiddled around with both Blackberrys thinking I might be doing something wrong while receiving, but no success.


Any idea whai I might be doing wrong?

I've got 99 problems and eclipse is all of them


Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: Stream Send Error - trying to send a file from BB to BB



What device models and software versions are you using to reproduce this issue?

How much data is being sent in the write()?

Does any data send before this error occurs?


Goodbye everybody!