1

我正在创建一个用于下载项目的类。我正在使用以下方法连接和检索下载信息:

public mDownload(String url) throws MalformedURLException {
    this.url = new URL(url);
}

private void connect() throws IOException {
    connection = url.openConnection();
    date = connection.getDate();
--> expiration = connection.getExpiration();
    length = connection.getContentLength();
    lastModified = connection.getLastModified();
}

但我有一些关于-->线路强制崩溃的报告:

java.lang.IllegalStateException: getInputStream() is not available. Is this a reentrant call?
        at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:524)
        at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:464)
        at java.net.URLConnection.getHeaderFieldDate(URLConnection.java:548)
        at java.net.HttpURLConnection.getHeaderFieldDate(HttpURLConnection.java:702)
        at java.net.URLConnection.getExpiration(URLConnection.java:426)

为什么会发生此错误,我该如何避免?谢谢!

4

1 回答 1

1

查看这个 commit,这可能是一个糟糕的异常消息。可能是响应未能返回任何数据。您可以通过监控实际的网络流量来确认。

于 2012-09-12T16:02:54.107 回答