Java URL Value Check checkURLStatus(String pURL)

Here you can find the source of checkURLStatus(String pURL)

Description

check URL Status

License

Open Source License

Declaration

public static boolean checkURLStatus(String pURL) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.net.HttpURLConnection;

import java.net.MalformedURLException;
import java.net.URL;

public class Main {
    public static boolean checkURLStatus(String pURL) {
        URL url = null;/*from www.  java2 s .c  om*/
        HttpURLConnection conn = null;
        try {
            url = new URL(pURL);
            conn = (HttpURLConnection) url.openConnection();
            // Commented these out for java 1.4, when moving to 1.6 comment these in again
            //conn.setReadTimeout(200);
            //conn.setConnectTimeout(200);
            conn.connect();
            return true;
        } catch (MalformedURLException e) {
            return false;
        } catch (IOException e) {
            return false;
        } finally {
            conn.disconnect();
            conn = null;
            url = null;
        }
    }
}

Related

  1. checkUrl(String url, int timeout)
  2. checkURL(URL check)
  3. checkUrl(URL url, URL baseUrl)
  4. checkURLAvailable(String targetUrl)
  5. checkUrlImage(final String url)
  6. checkURLValidProtocol(URL url)
  7. invokePostUrl(String url, String encodedQueryString)
  8. invokeUrl(String url)
  9. is200(final String url)