Java URL Value Check isHttpUrl(URL url)

Here you can find the source of isHttpUrl(URL url)

Description

Returns true if the specified url protocol is http.

License

Open Source License

Declaration

public static boolean isHttpUrl(URL url) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007, 2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
 * // w w w .  j  ava 2 s  . c  o  m
 * Contributors:
 *     Oracle - initial API and implementation
 ******************************************************************************/

import java.net.URL;

public class Main {
    /**
     * The <code>file</code> string indicating a url http protocol.
     */
    public static final String HTTP_PROTOCOL = "http";
    /**
     * The <code>file</code> string indicating a url http protocol.
     */
    public static final String HTTPS_PROTOCOL = "https";

    /**
     * Returns true if the specified url protocol is http.
     */
    public static boolean isHttpUrl(URL url) {
        String protocol = url.getProtocol();
        return url != null && (HTTP_PROTOCOL.equals(protocol) || HTTPS_PROTOCOL.equals(protocol));
    }
}

Related

  1. isHTTP(URL url)
  2. isHttpOk(String url)
  3. isHttpUrl(final URI toCheck)
  4. isHttpUrl(final URL url)
  5. isHttpUrl(String in)
  6. isHttpUrl(URL url)
  7. isHttpURLAvailable(final String url)
  8. isInternetReachable(String url)
  9. isJar(URL url)