诺基亚 5800 中 openInputStream 中的 io 异常
我正在使用以下代码从服务器解析 XML。
try {
//Open http connection
HttpConnection httpConnection = (HttpConnection) Connector.open(URL);
resultItem.setLabel("34");
this.sleep(1000);
//Initilialize XML parser
parser = new KXmlParser();
resultItem.setLabel("38");
this.sleep(1000);
resultItem.setLabel("39");
InputStreamReader isr=new InputStreamReader(httpConnection.openInputStream());
System.out.println("Input Sream: "+isr.read());
resultItem.setLabel("40");
this.sleep(1000);
parser.setInput(isr);
resultItem.setLabel("42");
this.sleep(1000);
parser.nextTag();
resultItem.setLabel("46");
this.sleep(1000);
parser.require(XmlPullParser.START_TAG, null, "login");
resultItem.setLabel("50");
this.sleep(1000);
//Iterate through our XML file
while (parser.nextTag() != XmlPullParser.END_TAG)
{
readXMLData(parser);
}
resultItem.setLabel("57");
this.sleep(1000);
parser.require(XmlPullParser.END_TAG, null, "login");
parser.next();
resultItem.setLabel("62");
this.sleep(1000);
resultItem.setLabel("64");
parser.require(XmlPullParser.END_DOCUMENT, null, null);
resultItem.setLabel("");
this.sleep(1000);
}
catch (Exception e)
{
e.printStackTrace();
resultItem.setLabel("Error:");
resultItem.setText( e.toString());
}
在 Nokia 2700
中工作正常,但在 InputStreamReader isr=new InputStreamReader(httpConnection.openInputStream());
中显示 IO 异常。为什么会发生这种情况?我该如何解决这个问题?
I am using the following code to parse XML from server.
try {
//Open http connection
HttpConnection httpConnection = (HttpConnection) Connector.open(URL);
resultItem.setLabel("34");
this.sleep(1000);
//Initilialize XML parser
parser = new KXmlParser();
resultItem.setLabel("38");
this.sleep(1000);
resultItem.setLabel("39");
InputStreamReader isr=new InputStreamReader(httpConnection.openInputStream());
System.out.println("Input Sream: "+isr.read());
resultItem.setLabel("40");
this.sleep(1000);
parser.setInput(isr);
resultItem.setLabel("42");
this.sleep(1000);
parser.nextTag();
resultItem.setLabel("46");
this.sleep(1000);
parser.require(XmlPullParser.START_TAG, null, "login");
resultItem.setLabel("50");
this.sleep(1000);
//Iterate through our XML file
while (parser.nextTag() != XmlPullParser.END_TAG)
{
readXMLData(parser);
}
resultItem.setLabel("57");
this.sleep(1000);
parser.require(XmlPullParser.END_TAG, null, "login");
parser.next();
resultItem.setLabel("62");
this.sleep(1000);
resultItem.setLabel("64");
parser.require(XmlPullParser.END_DOCUMENT, null, null);
resultItem.setLabel("");
this.sleep(1000);
}
catch (Exception e)
{
e.printStackTrace();
resultItem.setLabel("Error:");
resultItem.setText( e.toString());
}
It works fine in Nokia 2700
, but shows IO exception in InputStreamReader isr=new InputStreamReader(httpConnection.openInputStream());
. Why it is happening and how can I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有发送请求。这就是为什么你无法读取请求)
尝试这个:
You didn't send request. And let is why you can't read request )
Try this: