Java URL Connection urlExists(String urlString)

Here you can find the source of urlExists(String urlString)

Description

url Exists

License

Open Source License

Declaration

public static boolean urlExists(String urlString) 

Method Source Code


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

public class Main {
    public static boolean urlExists(String urlString) {
        InputStream is = null;//from   w w  w. ja v a2  s  .c  o m
        try {
            URL url = new URL(urlString);
            URLConnection con = url.openConnection();
            is = con.getInputStream();
            return true;
        } catch (Exception e) {
            return false;
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {

                }
            }
        }
    }
}

Related

  1. slurpStream(URLConnection conn)
  2. slurpURL(URL u, String encoding)
  3. slurpURLNoExceptions(URL u)
  4. url2list(String sURL, String encoding)
  5. urlContents(String urlString)
  6. URLExists(URL url, StringBuffer errorMsg)
  7. urlifyMap(Long nid, double latitude, double longitude)
  8. urlToHtm(String word, String findurl, String path)
  9. urlToReader(URL url)