Hi guys,
I'm working to a Java application that should send a file using OBEX and without need of a server application running on the other device. So I have implemented successfully device and service discovery (with the uuid 0x1105 for ObjectPush) but I have a great problem in the next section of the application: I have created connection but I've got an error on Operation.dataOutputStream() method...
Code:private void pushImage(String serviceURL){ HeaderSet hs = null; ClientSession cs = null; try { /* Start OBEX connection*/ cs = (ClientSession) Connector.open(serviceURL); hs = cs.connect( hs ); hs.getResponseCode(); hs = cs.createHeaderSet(); } catch (Exception e){ append(checkNo); append( new StringItem( "ERROR! ", "Error creating OBEX connection!", StringItem.PLAIN ) ); } ... try { hs.setHeader( HeaderSet.LENGTH, new Long((long)(file.length)) ); Operation op = cs.put(hs); // Debug message... append( new StringItem( "SUCCESS! ", "Start creation of DataOutputStream!", StringItem.PLAIN ) ); DataOutputStream out = op.openDataOutputStream(); // Debug message... append(checkOk); append( new StringItem( "SUCCESS! ", "Starting transferring!" + file.length, StringItem.PLAIN ) ); out.write( file, 0, file.length ); out.close(); op.close(); cs.disconnect(null); cs.close(); } catch (Exception e){ append(checkNo); append( new StringItem( "ERROR! ", "Sending file error: " + e.getClass() + e.getMessage(), StringItem.PLAIN ) ); } // Debug message... append(checkOk); append( new StringItem( "SUCCESS! ", "File successfully sended!", StringItem.PLAIN ) ); }
Anyone can help me? Thanks in advance.
P.S. I'm testing application with a Nokia N73

Reply With Quote

