Java URLConnection : how can I find out the size of a web file?

后端 未结 6 1503
一整个雨季
一整个雨季 2020-12-04 14:32

I\'m working on a project for school, and I\'m implementing a tool which can be used to download files from the web ( with a throttling option ). The thing is, I\'m gonna ha

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 15:18

    As @erickson said, sometimes there is header "Transfer-Encoding: chunked", instead of "Content-Length: " and of course you have null value for length.

    About the available() method - nobody can guarantee to you that it will return proper value, so I recommend you to not use it.

提交回复
热议问题