how to print a image via bluetooth using java me?

hello experts,

Anybody know how to print a image via bluetooth?

I try with this code, but isn´t works, if anybody knows what is wrong in this code or other form to do this, please tell me. I took the printer bluetooth adress directly from the printer.

I use java me MIDP 2.0, cellphone Nokia 5130 and a printer Epson pm 260.

The printer only acept images in JPG and TIFF format
//I try this, but isn´t work

try {
//reed the image from a file, and saved in a byte array (img)
FileConnection fc=(FileConnection)"file:///E:/Extra/imagen.jpg",Connector.READ_WRITE);
InputStream is=fc.openInputStream();

byte img[]=new byte[(int)fc.fileSize()];;


//do a bluetooth connection
StreamConnection btcon;
btcon =(StreamConnection)"btspp://00158336E722;master=false;encrypt=false;authenticate=false");

OutputStream output = btcon.openOutputStream();

//send the image to the printer


}catch(Exception e){System.err.println("error: " + e);}

Open in new window

Who is Participating?
Dear Dermofit,

I would like to know are you discovering the device and are you able to print the text to printer. I suppose looking at the piece of routine you must be discovering the device if not please do it. Further, if you are able to print the text and image is not being printed, I suppose it problem with the Image file.

Let me know as I am also working on the similar project.


Prasmin Mehta
DermofitAuthor Commented:
Thanks for you input Prasmin. It seems that for the moment our project will not be using bluetooh. Thanks, for your time though.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.