GET http://info.kib.ac.cn/down.asp?id=3964&no=1 HTTP/1.0
HOST: info.kib.ac.cnHTTP/1.1 302 Object moved
Server: Microsoft-IIS/5.0
Date: Mon, 14 Mar 2005 04:19:37 GMT
Location: http://info.kib.ac.cn/softwares/Adobe%20Reader%2070_chs_full.exe
Connection: Keep-Alive
Content-Length: 121
Content-Type: text/html
Set-Cookie: ASPSESSIONIDQCTDQBTB=KMKEAGDDMFKMHOBKFNJIIPGI; path=/
Cache-control: private所以读取Location属性就可以了

解决方案 »

  1.   

    首先判断返回头为302
    然后读取location
      

  2.   

    //打印回应的头信息
    public void logResponseHead( HttpURLConnection con ) {
    for( int i = 1; ; i++ ) {
    String header = con.getHeaderFieldKey( i );
    if( header != null ) {
    NetUtil.log( header + " : " + con.getHeaderField( header ) );
    } else {
    break;
    }
    }
    }结果:
    Server : Microsoft-IIS/5.0Date : Mon, 14 Mar 2005 06:16:16 GMTContent-Type : application/octet-streamLast-Modified : Tue, 25 Jan 2005 02:19:00 GMTETag : "082133b842c51:834"Content-Length : 25172913Content-Range : bytes 5518839-30691751/30691752
      

  3.   

    The following methods are used to access the header fields and the contents after the connection is made to the remote object: getContent 
    getHeaderField 
    getInputStream 
    getOutputStream 
    Certain header fields are accessed frequently. The methods: getContentEncoding 
    getContentLength 
    getContentType 
    getDate 
    getExpiration 
    getLastModifed
      

  4.   

    你遍历的代码错了直接con.getHeaderField("Location")
      

  5.   

    我有个连接类发给你,直接通过socket的,支持http代理Connect conn = new Connect("http://www.csdn.net");
    String out = conn.getInputString();
    CookieJar cookie = conn.cookie;
    String location = conn.getLocation();
    Connect有两种构造方法,并可以直接获得系统的cookie(采用jni,目前只支持window)
        public final CookieJar cookie;    public final URLParser urlParser;    public Connect(String url) {
            this(url, new CookieJar(url));
        }    public Connect(String url, CookieJar cookie) {
            this.urlParser = new URLParser(url);
            this.cookie = cookie;
            this.referer = urlParser.protocol + "://" + urlParser.host;
            addConnectListener(this);
        }
      

  6.   

    我的Email:[email protected]
    另外,遍历真的没错,直接con.getHeaderField("Location") is null