2010-06-12 101 views

回答

1

您需要javax.microedition.io.HttpConnection。鏈接的javadoc包含GET和POST的基本代碼示例。下面是GET示例的摘錄:

void getViaStreamConnection(String url) throws IOException { 
    StreamConnection c = null; 
    InputStream s = null; 
    try { 
     c = (StreamConnection)Connector.open(url); 
     s = c.openInputStream(); 
     int ch; 
     while ((ch = s.read()) != -1) { 
      ... 
     } 
    } finally { 
     if (s != null) 
      s.close(); 
     if (c != null) 
      c.close(); 
    } 
} 
+0

這是否允許我通過Get/Set發送數據? – LiamB 2010-06-12 15:07:15

+0

你讀過鏈接的javadoc嗎? – BalusC 2010-06-12 15:07:33

+0

我的壞,沒有看到鏈接。 - 謝謝 – LiamB 2010-06-12 15:09:13