2010-01-14 29 views
0

package com.intel.bluetooth.javadoc.ServicesSearch; import java.io.IOException; import java.io.OutputStream; import javax.microedition.io.Connector; import javax.obex。*; // import java.util.Vector;ServicesSearch錯誤作爲java中的符號未在netbeans中定義

公共類ObexPutClient {

public static void main(String[] args) throws IOException, InterruptedException { 

    String serverURL = null; // = "btgoep://0019639C4007:6"; 
    if ((args != null) && (args.length > 0)) { 
     serverURL = args[0]; 
    } 
    if (serverURL == null) { 
     String[] searchArgs = null; 
     // Connect to OBEXPutServer from examples 
     // searchArgs = new String[] { "11111111111111111111111111111123" }; 
     **ServicesSearch**.main(searchArgs); 
     if (ServicesSearch.serviceFound.size() == 0) { 
      System.out.println("OBEX service not found"); 
      return; 
     } 
     // Select the first service found 
     serverURL = (String)ServicesSearch.serviceFound.elementAt(0); 
    } 

    System.out.println("Connecting to " + serverURL); 

    ClientSession clientSession = (ClientSession) Connector.open(serverURL); 
    HeaderSet hsConnectReply = clientSession.connect(null); 
    if (hsConnectReply.getResponseCode() != ResponseCodes.OBEX_HTTP_OK) { 
     System.out.println("Failed to connect"); 
     return; 
    } 

    HeaderSet hsOperation = clientSession.createHeaderSet(); 
    hsOperation.setHeader(HeaderSet.NAME, "Hello.txt"); 
    hsOperation.setHeader(HeaderSet.TYPE, "text"); 

    //Create PUT Operation 
    Operation putOperation = clientSession.put(hsOperation); 

    // Send some text to server 
    byte data[] = "Hello world!".getBytes("iso-8859-1"); 
    OutputStream os = putOperation.openOutputStream(); 
    os.write(data); 
    os.close(); 

    putOperation.close(); 

    clientSession.disconnect(null); 

    clientSession.close(); 
} 

}

誰能幫我?的錯誤是在粗體字母。

謝謝

回答

0

你有ServicesSearch產生的?或包括在內?並導入(如果它存在於其他包中)。

向我們展示代碼,並告訴我們更多。