您的位置:首页 > 其它

get web url content length

2010-10-11 10:13 246 查看
public class ClientWithResponseHandler {

   

    public static void main(String[] args) {

        test("http://www.google.com");

    }

    public static String test(String url) {

        String result = "";

        try {

            URL httpurl = new URL(url);

            HttpURLConnection httpConn = (HttpURLConnection) httpurl.openConnection();           

            InputStream i=httpConn.getInputStream();

            int l=0;

            while(i.read()!=-1){

                l++;

            }

            System.out.println(l);

            i.close();

        } catch (Exception e) {

            e.printStackTrace();           

        }

        return result;

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  url web string exception class