0
我想獲得的數據發送GET請求到PHP服務,但不幸的是我沒有得到任何結果,我使用BlackBerry模擬器9800,這裏是我的代碼,黑莓GET請求
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();
}
}
請告訴我什麼是它存在的問題,