一个android关于网络的问题

图片说明
图片说明
图片说明
上面是一个小案例的代码,我debug了,说是line为空,就是没有读取到数据,可是为什么没有读取到数据呢?

     public static String getJsonByInternet(String path){
        try {
            URL url = new URL(path.trim());
            //打开连接
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

            if(200 == urlConnection.getResponseCode()){
                //得到输入流
                InputStream is =urlConnection.getInputStream();
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                byte[] buffer = new byte[1024];
                int len = 0;
                while(-1 != (len = is.read(buffer))){
                    baos.write(buffer,0,len);
                    baos.flush();
                }
                return baos.toString("utf-8");
            }
        }  catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }

你在子线程刷新UI,肯定刷不出来,可以用handler把你网络请求回的数据发送到主线程显示