Read error response body in Java

后端 未结 8 1414
暗喜
暗喜 2020-11-28 05:32

In Java, this code throws an exception when the HTTP result is 404 range:

URL url = new URL(\"http://stackoverflow.com/asdf404notfound\");
HttpURLConnection          


        
8条回答
  •  無奈伤痛
    2020-11-28 06:03

    I know that this doesn't answer the question directly, but instead of using the HTTP connection library provided by Sun, you might want to take a look at Commons HttpClient, which (in my opinion) has a far easier API to work with.

提交回复
热议问题