i write code receive file from mobile to pc using bluetooth, it work fine in sony ericsson mobile but nokia mobile it was not working please give me some soluction , thanks in advance.
pc server code
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package receiveapp; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import javax.bluetooth.*; import javax.microedition.io.Connector; import javax.obex.*; import java.util.UUID; public class OBEXPutServer { static final String serverUUID = "22222222222222222222222222222222"; static UUID uuid=null; static int count = 0; public static void main(String[] args) throws IOException { LocalDevice.getLocalDevice().setDiscoverable(Disco veryAgent.GIAC); SessionNotifier serverConnection = (SessionNotifier) Connector.open("btgoep://localhost:" + serverUUID + ";name=ObexExample"); try { while(true) { RequestHandler handler = new RequestHandler(); serverConnection.acceptAndOpen(handler); Thread.sleep(500); System.out.println("Received OBEX connection " + (++count)); } } catch(Exception e) { System.out.println("Received OBEX connection "+e.toString()); e.printStackTrace(); } } private static class RequestHandler extends ServerRequestHandler { public int onPut(Operation op) { try { uuid = UUID.randomUUID(); //String applicationDir="D:/WorkArea/Ramprasad/ram/NetBeansProjects/receiveapp/build/classes/Revc/"; String applicationDir="C:/Program Files/UniverCell/UniverCellCatLog/Recv/"; /* String applicationDir = getClass().getProtectionDomain().getCodeSource().g etLocation().getPath(); int lastApp=applicationDir.indexOf("/receiveapp.jar"); applicationDir=applicationDir.substring(0,lastApp) ; //Program%20Files applicationDir=applicationDir+"/Recv/"; // System.out.println("Path="+applicationDir); applicationDir=applicationDir.replaceAll("Program% 20Files","Program Files");*/ // System.out.println("Path="+applicationDir); java.io.InputStream is = op.openInputStream(); HeaderSet hs = op.getReceivedHeaders(); // HeaderSet hs = op.getType(); String name = (String) hs.getHeader(HeaderSet.NAME); Long stringLength = (Long) hs.getHeader(HeaderSet.LENGTH); System.out.println("[client:] Path= " +name); File f = new File(applicationDir+uuid+".txt"); FileOutputStream fos = new FileOutputStream (f); // byte b[] = new byte[1000]; byte b[]= new byte[ (int)stringLength.longValue() ]; int len=0; while ((len = is.read(b)) > 0) { fos.write (b, 0, len); } fos.close(); System.out.println("AbsolutePath " + f.getAbsolutePath()); StringBuffer buf = new StringBuffer(); int data; while ((data = is.read()) != -1) { buf.append((char) data); } System.out.println("got:" + buf.toString()); op.close(); return ResponseCodes.OBEX_HTTP_OK; } catch (IOException e) { e.printStackTrace(); // System.out.println("Insert BlurtoothDevice"); return ResponseCodes.OBEX_HTTP_UNAVAILABLE; } } public int onConnect(HeaderSet request, HeaderSet reply){ System.out.println("Hola"); return ResponseCodes.OBEX_HTTP_OK; } } }
put() method not trigger
i attach BlueCove version 2.1.0 on winsock jar how to solve please help me.