-
Connection not found
Hi all,
I'm trying to transfer file from my pc to mobile using bluetooth application
take a look at my code
public void serviceSearchCompleted()
{
try
{
System.out.println("First Line");
Connection connection = Connector.open(UStr);
System.out.println("Connection obtained");
ClientSession cs = (ClientSession)connection;
HeaderSet hs = cs.createHeaderSet();
cs.connect(hs);
System.out.println("OBEX session created");
//System.out.println("Response code of the server after connect..." +hs.getResponseCode());
File file = new File("C:\\AddImage\\ICICI_Advertisement.gif");
InputStream is = new FileInputStream(file);
byte filebytes[] = new byte[is.available()];
is.read(filebytes);
is.close();
hs = cs.createHeaderSet();
hs.setHeader(HeaderSet.NAME, file.getName());
hs.setHeader(HeaderSet.TYPE, "image/jpeg");
hs.setHeader(HeaderSet.LENGTH, new Long(filebytes.length));
Operation putOperation = cs.put(hs);
System.out.println("Pushing file: " + file.getName());
System.out.println("Total file size: " + filebytes.length + " bytes");
OutputStream outputStream = putOperation.openOutputStream();
outputStream.write(filebytes);
System.out.println("File push complete");
outputStream.close();
putOperation.close();
cs.disconnect(null);
connection.close();
}
catch(Exception e)
{
System.out.println("connection:"+e);
}
}
it is trrowing the exception as:
javax.microedition.io.ConnectionNotFoundException
could anyone help me regarding this.........
-
oh! i also have a proplem same you but with me,i send file sound .wav from a PC to mobile but i haven't successfull!.