Java URL Connection isValidUrl(String input)

Here you can find the source of isValidUrl(String input)

Description

is Valid Url

License

Apache License

Declaration

public static boolean isValidUrl(String input) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.net.URI;
import java.net.URL;

public class Main {
    public static boolean isValidUrl(String input) {
        if (!input.startsWith("http://") && !input.startsWith("https://")) {
            input = ("http://" + input);
        }/*  w w w.j ava 2  s  .  co  m*/
        try {
            URI uri = new URI(input);
            URL url = uri.toURL();
            java.net.URLConnection conn = url.openConnection();
            conn.connect();
            return true;
        } catch (Exception ignored) {
        }
        return false;
    }
}

Related

  1. imageFromUrl(String url)
  2. isJarDirectory(JarURLConnection conn)
  3. isOnline(String url)
  4. isUrlReachable(String url)
  5. isValidToc(URL url)
  6. isZipName(URI documentIRI, URLConnection connection)
  7. jarURLDirectories(URL jarURL)
  8. jarURLEntryResource(String jarURLString)
  9. lastModifiedURL(String urlstr)