I’m getting a 503 response from a server that I’m trying to communicate with. Now, it shows me this in the log, but, I want to catch the IOException that it fires and deal with it if and only if the response code is 503, and nothing else. How would I do this?
EDIT:
Here’s part of my code:
inURL = new BufferedReader(new InputStreamReader(myURL.openStream()));
String str;
while ((str = inURL.readLine()) != null) {
writeTo.write(str + "\n");
}
inURL.close();
If using
java.net.HttpURLConnection, use the methodgetResponseCode()If using
org.apache.commons.httpclient.HttpClient,executeMethod(...)returns the response code