安卓从网站读数据时遇到偶发异常java.io.EOFException

代码如下
package com.example.aaa;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
caonima("http://www.weather.com.cn/data/cityinfo/101010100.html");
}

public void caonima(final String address){
    new Thread(new Runnable(){
        @Override
        public void run() {
            HttpURLConnection connection=null;
            try {
                URL url=new URL(address);
                connection=(HttpURLConnection) url.openConnection();
                connection.setRequestMethod("GET");
                connection.setConnectTimeout(8000);
                connection.setReadTimeout(8000);
                InputStream in=connection.getInputStream();
                BufferedReader reader=new BufferedReader(new InputStreamReader(in));
                StringBuilder response=new StringBuilder();
                String line;
                while((line=reader.readLine())!=null){
                    response.append(line);
                }                                           
                System.out.println(response.toString());

            } catch (Exception e) {
                System.out.println( e.toString());

            }finally{
                if(connection!=null){
                    connection.disconnect();
                }
            }

}

    }).start();
}

}
同类型有些address会进这个异常,但有些不会进,
(这些address在浏览器输入网站返回的json数据都是正常的)

http://blog.sina.com.cn/s/blog_3fe961ae0100mpxh.html

这个我看过了,还是不能解决,有些特定地址正常运行,而有些却不可以让我无法理解

你改成https试下,现在很多都重定向为http为https了

或者使用网络框架,比如okhttp,它底层自动实现重定向了