You can get this information using java.net.HttpURLConnection :
URL url = new URL("http://stackoverflow.com/"); URLConnection urlConnection = url.openConnection(); if (urlConnection instanceof HttpURLConnection) { int responseCode = ((HttpURLConnection) urlConnection).getResponseCode(); switch (responseCode) { case HttpURLConnection.HTTP_OK: // HTTP Status-Code 302: Temporary Redirect. break; case HttpURLConnection.HTTP_MOVED_TEMP: // HTTP Status-Code 302: Temporary Redirect. break; case HttpURLConnection.HTTP_NOT_FOUND: // HTTP Status-Code 404: Not Found. break; } }
user588961
source share