2010-01-14 68 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产生的?或包括在内?并导入(如果它存在于其他包中)。

向我们展示代码,并告诉我们更多。

相关问题