HttpConnection c = null;
InputStream is = null;
StringBuffer sb = new StringBuffer();
String request = serverUrl; // + "?loc=" + location.getLat() + "," + location.getLng() + "data=" + message.getString();
try {
c = (HttpConnection) Connector.open("http://www.google.com");
c.setRequestMethod(HttpConnection.GET); //default
is = c.openInputStream(); // transition to connected!
int ch = 0;
for (int ccnt = 0; ccnt < 150; ccnt++) { // get the title.
ch = is.read();
if (ch == -1) {
break;
}
sb.append((char) ch);
return sb.toString();
}
} catch (IOException x) {
x.printStackTrace();
} finally {
try {
is.close();
c.close();
} catch (IOException x) {
x.printStackTrace();
}
}
System.out.println(sb.toString());
return null;
在上面的代码中——这一行
(HttpConnection) Connector.open("http://www.google.com");
不响应。我能做些什么来解决这个问题?