Here you can find the source of isHttpUrl(final URI toCheck)
Parameter | Description |
---|---|
toCheck | The URI to check |
public static boolean isHttpUrl(final URI toCheck)
//package com.java2s; /*/*from w w w.ja va2 s. c om*/ * Copyright 2016 Johns Hopkins University * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.net.URI; import java.net.URISyntaxException; public class Main { /** * Determine if a URL is a URL using HTTP or HTTPS protocols * * @param toCheck The URI to check * @return true if the URI is a URL with a non-empty host and uses either the http or https protocol */ public static boolean isHttpUrl(final URI toCheck) { return toCheck.getHost() != null && (toCheck.getScheme().equals("http") || toCheck.getScheme().equals("https")); } /** * Determine if a string is a URL with HTTP or HTTPS protocols * * @param toCheck the string to check * @return true if the string is a URL with http or https protocols */ public static boolean isHttpUrl(final String toCheck) { try { return isHttpUrl(new URI(toCheck)); } catch (final URISyntaxException e) { return false; } } }