List of utility methods to do URL Redirect
String | getRedirectedUrl(String url) get Redirected Url HttpURLConnection connection; String finalUrl = url; do { connection = (HttpURLConnection) new URL(finalUrl).openConnection(); connection.setInstanceFollowRedirects(false); connection.setUseCaches(false); connection.setRequestMethod("GET"); connection.connect(); ... |
URL | getRedirectUrl(final URL url) Sends a request to the given URL and checks, if it contains a redirect. try { URL internalUrl = url; URL previousUrl = null; int redirectCtr = 0; while (internalUrl != null && redirectCtr < MAX_REDIRECT_COUNT) { redirectCtr++; final HttpURLConnection urlConn = (HttpURLConnection) internalUrl.openConnection(); urlConn.setAllowUserInteraction(false); ... |