title: send file from pc to android mobile via bluetooth
body: <p>I am developing a desktop application using java to send a file to android devices. I followed this article <a href="http://www.substanceofcode.com/2008/06/20/sending-files-to-mobile-phone-using-bluetooth-and-obex/" rel="nofollow">sending-files-to-mobile-phone-using-bluetooth-and-obex</a> to develop it. I tested it in mobile, java based and it works fine but in android mobile I get this exception:</p>
  
  <pre><code>Exception: Failed to connect;    
  [10051] Une opération a été tentée sur un réseau impossible à atteindre.  
  javax.bluetooth.BluetoothConnectionException: Failed to connect;  
  [10051] Une opération a été tentée sur un réseau impossible à atteindre.  
  at com.intel.bluetooth.BluetoothStackMicrosoft.connect(Native Method)  
  at com.intel.bluetooth.BluetoothStackMicrosoft.access$700(BluetoothStackMicrosoft.java:44)  
  at com.intel.bluetooth.BluetoothStackMicrosoft$ConnectThread.run(BluetoothStackMicrosoft.java:651)
  </code></pre>
  
  <p>here there is the code of send:</p>
  
  <pre><code>public class SendFile implements Runnable {
  private String btConnectionURL;
  private byte[] file;
  private String filename;
  
  public SendFile (String url, byte[] file, String filename) {
      this.btConnectionURL = url;
      this.file = file;
      this.filename = filename;
  }
  
  public void run() {
  
      try {
  
          Connection connection = Connector.open(btConnectionURL);
          // connection obtained
  
          // now, let's create a session and a headerset objects
          ClientSession cs = (ClientSession) connection;
  
  
  
          HeaderSet hs = cs.createHeaderSet();
  
          // now let's send the connect header
          cs.connect(hs);
  
          hs.setHeader(HeaderSet.NAME, filename);
          hs.setHeader(HeaderSet.TYPE, "image/jpeg");
          hs.setHeader(HeaderSet.LENGTH, new Long(file.length));
  
          Operation putOperation = cs.put(hs);
  
          OutputStream outputStream = putOperation.openOutputStream();
          outputStream.write(file);
          // file push complete
  
          outputStream.close();
          putOperation.close();
  
          cs.disconnect(null);
  
          connection.close();
      } catch (Exception e) {
          System.err.println("Exception: " + e.getMessage());
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>