S40手机联网问题

阿冲 2006-11-12 10:34:21
S40手机在获取网页时有部分机型在Connector.open()这句会报空指针异常,,,另一部分机型在获取网页时则一直返回wmlc编码,,,似乎所有的S40机型都有上面两个问题,,,同样的代码在别的机型上则没有任何问题,,,代码如下:

if (this.netType == 0) {
hCon = (HttpConnection) Connector.open("http://10.0.0.172:80" + url.substring(url.indexOf("/" , index)) , Connector.READ_WRITE , true);
hCon.setRequestProperty("X-Online-Host" , serverName);
} else {
hCon = (HttpConnection) Connector.open(url , Connector.READ_WRITE , true);
}

if (checkURL != null) {
hCon.setRequestProperty("Referer" , checkURL);
int i = url.indexOf("xid=") + 4;
hCon.setRequestProperty("xid" , url.substring(i , url.indexOf("?")));
}

this.contentTextBox.setString(serverName + " : " + url);

if (hCon.getResponseCode() == HttpConnection.HTTP_OK) {
this.contentTextBox.setString("HTTP_OK");
is = hCon.openInputStream();
this.contentTextBox.setString("Stream is open");

int len;
byte[] data = null;
byte[] temp = null;
this.contentTextBox.setString("Read data start");
while ((len = is.read(buffer))!= -1) {
if (data == null) {
data = new byte[len];
System.arraycopy(buffer , 0 , data , 0 , len);
} else {
temp = new byte[data.length + len];
System.arraycopy(data , 0 , temp , 0 , data.length);
System.arraycopy(buffer , 0 , temp , data.length , len);
data = temp;
}
}
temp = null;

backContent = new String(data);
}
...全文
218 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧