HttpConnection hc =null;
DataInputStream is=null; // hc.openInputStream();
StringBuffer str = new StringBuffer();
try
{
hc =(HttpConnection) Connector.open(url);
is = new DataInputStream(hc.openDataInputStream());
int ch;
while ((ch=is.read())!=-1)
{
str.append((char) ch);
}
}
catch(Exception e)
{
e.printStackTrace();
str.append("open Error");
}
finally
{
try
{
if (is!=null) is.close();
if (hc!=null) hc.close();
}
catch(IOException ioe)
{
ioe.printStackTrace();
str.append("close Error");
}
}
return str.toString();
}
在模拟器无法取得数据,在真机上也无法取得数据。
真机上[JAVA应用]-[设置]-[默认连接]-CMWAP和CMNET都测试过,依然无法取得数据
有些没有数据返回,有些返回的数据为<html><head><title>Error</title></head><body>The parameter is incorrect.</body></html>
url="www.abkk.com"返回上述回应
url="www.yahoo.com"则没有返回,
为什么会这样?