Broken link checker - Java
Broken link checker
Snippet Code
This program will check a webpage whether the page containing any broken link or not
import java.net.HttpURLConnection;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.util.Collection;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.parser.ParserDelegator;
import java.util.LinkedHashSet;
import javax.swing.text.MutableAttributeSet;
public class BrokenLinkFinder{
public static boolean isLive(String link) {
HttpURLConnection urlConnection = null;
try{
URL url = new URL(link);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
String redirectLink = urlConnection.getHeaderField("Location");
if (redirectLink != null
Tags