HttpURLConnection java.io.FileNotFoundException

前端 未结 3 1622
温柔的废话
温柔的废话 2020-12-07 22:50

The code below works great if I connect to what seems to be Apache servers, however when I try to connect to my .Net server it throws an error. I am guessing it is a header

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 23:17

    I faced an issue, where executing a HEAD-Request threw a FileNotFoundException.
    The reason is, that a response to a HEAD does not have a body and therefore a call to getInputStream throws a FileNotFoundException.

    So if you are executing a HEAD, you should not try to get the InputStream.

提交回复
热议问题