http://www-900.ibm.com/developerWorks/cn/java/joy-down/index.shtml
看看这个对你应该有帮助的

解决方案 »

  1.   

    服务器收到请求后,按要求寻找请求的文件,提取文件的信息,然后返回给浏览器,返回信息如下:
    200
    Content-Length=106786028 //应该是这个长度 你得到它的头部信息应该就可以了
    Accept-Ranges=bytes
    Date=Mon, 30 Apr 2001 12:56:11 GMT
    ETag=W/"02ca57e173c11:95b"
    Content-Type=application/octet-stream
    Server=Microsoft-IIS/5.0
    Last-Modified=Mon, 30 Apr 2001 12:56:11 GMT
      

  2.   

    //test t = new test();
        URL url=new URL("http://zeal.3322.org:6789/aaa.rar");
        HttpURLConnection conn=(HttpURLConnection)url.openConnection();
        conn.connect();
        //InputStream is=conn.getInputStream();    System.out.println(conn.getContentLength());