j2me程序在联想i909上的联网问题
ucweb 在i909上运行的很正常。
我自己写的通过移动wap网关的连接,怎么都连接不上,总是抛出io异常。
请高手同志帮我解决下。
下面的代码是根据别人的修改的
String url = "211.103.181.70:8080";
String server = "searWeb/index.jsp";
try {
// // 写入数据
// // 真机通过移动网关连接URL
if (first) { // 第一次连接,什么都不做,把返回信息直接丢掉,然后关闭连接,并把FIRST置为FALSE
con = (HttpConnection) Connector.open("http://10.0.0.172:80/"
+ server);
con.setRequestProperty("X-Online-Host", url);
is = con.openInputStream();
byte b[] = this.loadData(is);
String str = new String(b, "UTF-8");
this.append(str);
is.close();
is = null;
con.close();
con = null;
first = false;
}
//
// // 第二次连接,并且处理返回信息,显示到屏幕上
con = (HttpConnection) Connector.open("http://10.0.0.172:80/"
+ server);
con.setRequestProperty("X-Online-Host", url);
// 模拟器上直接连接URL
// con = (HttpConnection) Connector.open("http://" + url + "/"
// + server);
// String s = con.getEncoding();
// System.out.println(s);
if (first == false) {
is = con.openInputStream();
byte b[] = this.loadData(is);
String str = new String(b, "UTF-8");
StringItem strI = new StringItem("" + (++count), str);
this.append(strI);
}
// }
} catch (Exception e) {
// System.out.println(e);
StringItem strI = new StringItem(e.toString(), "first"
+ e.getMessage());
this.append(strI);
} finally {
try {
if (is != null) {
is.close();
}
if (con != null) {
con.close();
}
} catch (Exception e) {
StringItem strI = new StringItem(e.getMessage(), "second"
+ e.getMessage());
this.append(strI);
}