Checks the availability of a URL by openening a reading stream on it.

@param url
the url to check

@return <code>true</code> if the URL can be read
175570
protected boolean isAvailable(URL url) {

        try (InputStream inputStream = url.openStream()) {
            return true;
        } catch (IOException e) { //NOSONAR
            LOG.debug("URL {} not available", url, e);
            return false;
        }
    }
940450
public static InputStream openUncachedStream(URL url) throws IOException {
        URLConnection urlConnection = url.openConnection();
        urlConnection.setUseCaches(false);
        return urlConnection.getInputStream();
    }
556091
public static boolean isHttp(String url) {
		if (url.length() < 7 || !url.startsWith("http")) {
			return false;
		}
		int i = 4; // "http"
		if (url.charAt(i) == 's') {
			i++;
		}
		return url.startsWith("://", i);
	}
1103436
public static boolean isExternalUrl(String url) {
        return URL_PATTERN.matcher(url).matches() || SPECIAL_URL_PATTERN.matcher(url).matches();
    }
147239
public boolean equalUrl(ReqUrl url) {
        return url.getMethod().equalsIgnoreCase(this.method) && url.getUrl().equalsIgnoreCase(this.url);
    }
434270
public static Exception checkGrpcUrl(String url) {
        try {

            parseGrpcUrl(url);
            return null;

        } catch (Exception e) {
            return e;
        }
    }
806281
public void setUrl(String url) {
        if (url != null && url.trim().length() > 0) {
            if (Url.isUrl(url)) {
                this.url = url;
            } else {
                throw new IllegalArgumentException(url + " is not a valid URL.");
            }
        }
    }
347179
public static InputStream getStream(URL url) {
		Assert.notNull(url);
		try {
			return url.openStream();
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
747732
public static Properties load(URL url) throws IOException {
        InputStream fis = null;
        try {
            Properties props = new Properties();
            fis = url.openStream();
            props.load(fis);
            return props;
        } finally {
            IOUtils.closeQuietly(fis);
        }
    }
1103150
public static boolean containsURL(final URL[] urls, final URL url) {
        checkNotNull("urls", urls);
        checkNotNull("url", url);
        for (int i = 0; i < urls.length; i++) {
            final URL element = urls[i];
            final String elementStr = element.toExternalForm();
            final String urlStr = url.toExternalForm();
            if (elementStr.equals(urlStr)) {
                return true;
            }
        }
        return false;
    }
643612
public static boolean showDocument(URL url) {
        return showDocumentViaDesktop(url)
            || showDocumentViaExec(url)
            || JavaWebStart.showViaWebStart(url);
    }
66269
def read(url, **kwargs):
    
    response = open_url(url, **kwargs)
    try:
        return response.read()
    finally:
        response.close()
429202
public static void loadPropertiesFromURL(URL url) {
        if (url == null) {
            return;
        }
        InputStream in = null;
        try {
            in = url.openStream();
            properties.load(in);
        } catch (IOException e) {
            AnalysisContext.logError("Unable to load properties from " + url, e);
        } finally {
            IO.close(in);
        }
    }
436338
public static String readUrlContentQuietly( String url, Logger logger ) {

		String result = "";
		try {
			result = readUrlContent( url );

		} catch( Exception e ) {
			logger.severe( "Content of URL " + url + " could not be read." );
			logException( logger, e );
		}

		return result;
	}
649854
private static Boolean openURLinUnixOS(final String url)
		throws InterruptedException, IOException, Exception
	{
		Boolean executed = false;
		for (final Browsers browser : Browsers.values())
		{
			if (!executed)
			{
				executed = Runtime.getRuntime()
					.exec(new String[] { UNIX_COMMAND_WHICH, browser.getBrowserName() })
					.waitFor() == 0;
				if (executed)
				{
					Runtime.getRuntime().exec(new String[] { browser.getBrowserName(), url });
				}
			}
		}
		if (!executed)
		{
			throw new Exception(Arrays.toString(Browsers.values()));
		}
		return executed;
	}
765434
public final static boolean isValidURL(String url) {
        if (url == null) {
            return false;
        } else {
            return Patterns.WEB_URL.matcher(url).matches();
        }
    }
377195
public static synchronized boolean canConnect(String url) {
        boolean result = false;
        HttpURLConnection conn = null;
        try {
            conn = getNormalCon(formatUrl(url));
            conn.connect();

            int resultCode = conn.getResponseCode();
            result = (200 == resultCode);

                /*
            if (!result) {
                Log.d("canConnect", resultCode + "|" + url);
            }
            // */

        } catch (IOException e) {
            result = false;
//            Log.e("canConnect", url + "|error:" + e.toString());
        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }

        return result;
    }