Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You can get the HTTP status of these links.
Here is a simple example (the code below can be shortened and simplified):
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class URLChecker {
public static int checkUrl(String currentUrl) {
URL checkUrl = null;
HttpURLConnection http = null;
int statusCode = 0;
try {
checkUrl = new URL(currentUrl);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
if (checkUrl != null) {
http = (HttpURLConnection)checkUrl.openConnection();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (http != null) {
statusCode = http.getResponseCode();
}
} catch (IOException e) {
e.printStackTrace();
}
return statusCode;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question