【发布时间】:2011-06-17 13:47:16
【问题描述】:
我正在尝试获取向 php 服务发送 GET 请求的数据,但不幸的是我没有得到任何结果,我使用的是 Blackberry Simulator 9800,这是我的代码,
HttpConnection conn = null;
InputStream in = null;
StringBuffer buff = new StringBuffer();
String result = "";
String url = "http://www.devbrats.com/testing/ActorRated/Service/cities.php";
try{
conn = (HttpConnection) Connector.open(url,Connector.READ_WRITE, true);
conn.setRequestMethod(HttpConnection.GET);
conn.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Confirguration/CLDC-1.0");
if(conn.getResponseCode() == HttpConnection.HTTP_OK){
in = conn.openInputStream();
//parser.parse(in, handler);
buff.append(IOUtilities.streamToBytes(in));
result = buff.toString();
}
else{
result = "Error in connection";
}
} catch(Exception ex){
ex.printStackTrace();
} finally{
try {
if(in != null){
in.close();
}
conn.close();
} catch (IOException e) {
e.printStackTrace();
}
}
请告诉我这是什么问题,
【问题讨论】:
标签: blackberry java-me get request