有一个J2ME的技术问题
下面的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!”的错误?