Java URL Value Check checkUrl(String inputUrlString)

Here you can find the source of checkUrl(String inputUrlString)

Description

check Url

License

Open Source License

Declaration

public static boolean checkUrl(String inputUrlString) throws IOException 

Method Source Code


//package com.java2s;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static boolean checkUrl(String inputUrlString) throws IOException {
        URL url = new URL(inputUrlString);
        return checkUrl(url);
    }/*from w w w . ja  va 2s. co  m*/

    public static boolean checkUrl(URL inputUrl) throws IOException {
        HttpURLConnection huc = (HttpURLConnection) inputUrl.openConnection();
        huc.setRequestMethod("GET");
        huc.connect();
        if (HttpURLConnection.HTTP_OK == huc.getResponseCode()) {
            return true;
        }
        return false;
    }
}

Related

  1. checkUrl(final String link)
  2. checkURL(String _url)
  3. checkUrl(String url, int timeout)
  4. checkURL(URL check)
  5. checkUrl(URL url, URL baseUrl)
  6. checkURLAvailable(String targetUrl)