int count=0;
String urlStr ="http://地址";
try
{
URL url = new URL(urlStr);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(),"GBK"));
String line=null;
do
{
line = reader.readLine();
if(line!=null)
{
str +=line;
}
}
while(line!=null);
reader.close();
count = 0;
return str;
}
catch (Exception e)
{
e.printStackTrace();
String qq01 = "网络异常01开始:("+e.getMessage()+")结束!";
String qq02 = "网络异常02开始:("+e.getLocalizedMessage()+")结束!";
System.out.println(qq01);
System.out.println(qq02);
count++;
if("Connection timed out".equals(e.getMessage()) && count<3)//出现异常时连续调用两次
{
回调方法();
}
return "6";
}