13,100
社区成员
发帖
与我相关
我的任务
分享
public static int debug;
public static String getMessageHttpConnection(String url)
{
HttpConnection c = null;
InputStream is = null;
int rc = 0;
String str = "";
try
{
debug=0;
System.out.println("cnecting...........");
try
{
c = (HttpConnection) Connector.open(url);
rc = c.getResponseCode();
c = null;
c = (HttpConnection) Connector.open(url);
rc = c.getResponseCode();
debug=1;
}
catch (IOException e)
{
System.out.println("cmnet is fiail");
try
{
debug=2;
c = null;
c = (HttpConnection) Connector.open("http://10.0.0.172:80/lottery/wap/issue_info.htm", Connector.READ, true);
c.setRequestProperty("X-Online-Host", "http://caipiao.wap.taobao.com");
c.getResponseCode();
c = null;
c = (HttpConnection) Connector.open("http://10.0.0.172:80/lottery/wap/issue_info.htm", Connector.READ, true);
c.setRequestProperty("X-Online-Host", "http://caipiao.wap.taobao.com");
rc = c.getResponseCode();
debug=3;
}
catch (Exception ex)
{
debug=4;
System.out.println("cmwap is fiali");
str="";
GameScreen.isNotic = true;
}
}
try
{
if( rc == HttpConnection.HTTP_OK )
{
is = c.openInputStream();
data = new byte[832];
int actual = 0;
int bytesread = 0;
while ((bytesread != data.length) && (actual != -1))
{
actual = is.read(data, bytesread, data.length - bytesread);
bytesread += actual;
}
c.close();
is.close();
str = new String(data, "utf-8");
System.out.println("conect is ok");
debug=5;
}
else
{
debug=6;
str="";
System.out.println("conect is falil");
GameScreen.isNotic = true;
}
}
catch (IOException e)
{
str="";
System.out.println("conect is falil");
e.printStackTrace();
GameScreen.isNotic = true;
}
debug=7;
}
catch (Exception e)
{
// TODO: handle exception
str="";
GameScreen.mid.destroyApp(true);
e.printStackTrace();
}
debug=8;
return str;
}