Java URL Value Check isURL(final String urlString)

Here you can find the source of isURL(final String urlString)

Description

Check if a URL is actually a URL

License

Open Source License

Parameter

Parameter Description
url Possible URL

Return

true if considered a URL

Declaration

@SuppressWarnings("nls")
public static boolean isURL(final String urlString) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Oak Ridge National Laboratory.
 * 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
 ******************************************************************************/

import java.net.URL;

public class Main {
    /** Check if a URL is actually a URL
     *  @param url Possible URL/*from w  w w  . j  av  a  2  s .c o m*/
     *  @return <code>true</code> if considered a URL
     */
    @SuppressWarnings("nls")
    public static boolean isURL(final String urlString) {
        try {
            new URL(urlString);
        } catch (Exception e) {
            return false;
        }
        return true;
        //        return urlString.contains(":/");  //$NON-NLS-1$
    }
}

Related

  1. isLocalURL(URL url)
  2. isNewer(URL file, URL reference)
  3. isResponseCode(String url, int expectedCode)
  4. isResponsive(URL url)
  5. isSameFile(URL u, File out)
  6. isURL(Object obj)
  7. isUrl(String input)
  8. isURL(String name)
  9. isURL(String possibleURL)