Requires code in java that will catch all anchor tags from page, store them & check broken or not

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

answered by (171 points)
selected by
0 votes
Best answer

First you can find appropriate link. Identify an element and get attribute href.


We can use HttpURLConnection Class and getResponseCode method for finding the reponse code of the URL.

public static int getResponseCode(String urlString) throws MalformedURLException, IOException {
     URL u = new URL(urlString);
     HttpURLConnection huc =  (HttpURLConnection)  u.openConnection();
     return huc.getResponseCode();