that is code to send file from pc to phon but it dont run and throw
that exception

java.io.IOException: Device not discovered

i dont know what is the problem

try {
   String adr ="btgoep://000E6D80ABBE:9" ;
   System.out.println("addres");
   ClientSession cs = (ClientSession)OBEXConnector.open(adr);
   System.out.println("opening");
   HeaderSet hs = cs.connect(cs.createHeaderSet());
   System.out.println("created header set");
   byte text[] = "Test Message from
avetanaBlueooth".getBytes("iso-8859-1");
   hs.setHeader (HeaderSet.NAME, "ana.txt");
   hs.setHeader (HeaderSet.TYPE, "ana");
   //hs.setHeader(0x49, text);
   System.out.println("putting....");
   Operation po = cs.put(hs);
   System.out.println("put....");
   po.openOutputStream().write(text);
   po.close();
   cs.disconnect(null);
   cs.close();
   System.out.println("closed...");
   } catch (Exception e) { System.out.println(e);

   }

Recommended Answers

All 5 Replies

Do you have have Bluetooth or infrared hardware on your computer?

yes i have bluetooth device and work with BlueSoleil stack
then what i can do

Can you post the whole code?

import de.avetana.javax.obex.*;
import de.avetana.obexsolo.*;

public static void main(String[]args){

try {
   String adr ="btgoep://000E6D80ABBE:9" ;
   System.out.println("addres");
   ClientSession cs = (ClientSession)OBEXConnector.open(adr);
   System.out.println("opening");
   HeaderSet hs = cs.connect(cs.createHeaderSet());
   System.out.println("created header set");
   byte text[] = "Test Message from
avetanaBlueooth".getBytes("iso-8859-1");
   hs.setHeader (HeaderSet.NAME, "ana.txt");
   hs.setHeader (HeaderSet.TYPE, "ana");
   //hs.setHeader(0x49, text);
   System.out.println("putting....");
   Operation po = cs.put(hs);
   System.out.println("put....");
   po.openOutputStream().write(text);
   po.close();
   cs.disconnect(null);
   cs.close();
   System.out.println("closed...");
   } catch (Exception e) { System.out.println(e);

   }
}

Not supriced that is not working, I'm sorry to say you just "hacked" something together.
Have look at this IBM tutorial

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.