If the response code isn’t 200 or 2xx, use getErrorStream()
instead of getInputStream().
More Related Contents:
- How to use java.net.URLConnection to fire and handle HTTP requests
- Java – sending HTTP parameters via POST method easily
- How do I do a HTTP GET in Java? [duplicate]
- How to enable wire logging for a java HttpURLConnection traffic?
- How to Reuse HttpUrlConnection? [duplicate]
- Read error response body in Java
- How to modify the header of a HttpUrlConnection
- Can I override the Host header where using java’s HttpUrlConnection class?
- Android’s HttpURLConnection throws EOFException on HEAD requests
- “PKIX path building failed” and “unable to find valid certification path to requested target”
- Connecting to remote URL which requires authentication using Java
- Android download binary file problems
- Authenticated HTTP proxy with Java
- REST – HTTP Post Multipart with JSON
- Sending a JSON HTTP POST request from Android
- Getting java.net.SocketTimeoutException: Connection timed out in android
- Persistent HttpURLConnection in Java
- Java HTTP Client Request with defined timeout
- Preemptive Basic Auth with HttpUrlConnection?
- Check if file exists on remote server using its URL [duplicate]
- Accessing post variables using Java Servlets
- How can I read an HttpServletReponses output stream?
- Send HTTP request manually via socket
- HttpURLConnection.getResponseCode() returns -1 on second invocation
- How to get host name with port from a http or https request
- How to send Request payload to REST API in java?
- how to resume an interrupted download
- Asynchronous HTTP Client for Java
- posting XML request in java
- How can I use an HTTP proxy for a JAX-WS request without setting a system-wide property?