Does java.net.HttpUrlConnection always throw IOException if there is an error status return by Server?
问题 I am using java.net.HttpUrlConnection to make Http request to my Server. I realized that if the Server return an error status (400 for example). HttpUrlConnection will throw an IOException corresponding to the error status. My question is: Does HttpUrlConnection always throw an IOException if the server return an error status (4xx, 5xx)? I take a look at HttpUrlConnection API description but I couldn't answer my question. Updated: Please see my test: public static void main(String[] args) {