有一个J2ME的技术问题

czhfun 2003-08-09 12:37:42
下面的J2ME代码是在siemens的模拟器上运行的:(其中http://210.32.25.204是局域网内的PC)
String url = "http://210.32.25.204/";
HttpConnection conn = null;
DataInputStream iStrm = null ;
try
{
conn = (HttpConnection) Connector.open(url);
iStrm = conn.openDataInputStream();
int status = conn.getResponseCode();
if(status == conn.HTTP_OK)
{
int length = (int)conn.getLength();
System.out.print("http response length=");
System.out.println(length);
}
else
{
System.out.print("http_error");
}
}
catch(IOException e)
{
System.out.println("Connection Occur Error!");
}
运行结果是“http response length=-1”
为什么上面的结果等于“-1”?
而且假如把变量url改成Internet上的地址如“http://ww.google.com”就显示“Connection Occur Error!”的错误?
...全文
22 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
czhfun 2003-08-09
  • 打赏
  • 举报
回复
异常是null?所以不知道是什么出错
miaoliujun 2003-08-09
  • 打赏
  • 举报
回复
你把异常显示出来,这种情况是没有遇到

791

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 其他移动相关
社区管理员
  • 移动开发其他问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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