Java URL Value Check isWellFormedURL(String url_str)

Here you can find the source of isWellFormedURL(String url_str)

Description

Check if specified string is well formed

License

Open Source License

Declaration

static public boolean isWellFormedURL(String url_str) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2005-2011 eBay Inc./*from   ww  w  .j  ava2  s  . c o  m*/
 * 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.MalformedURLException;
import java.net.URL;

public class Main {
    /**
     * Check if specified string is well formed
     */
    static public boolean isWellFormedURL(String url_str) {
        if (url_str == null)
            return false;
        try {
            new URL(url_str);
            return true;
        } catch (MalformedURLException e) {
            return false;
        }
    }
}

Related

  1. isValidUrl(URI uri)
  2. isValidURL(URL url)
  3. isValidUrlDataType(URL value)
  4. isValidURLWithoutProtocol(String value)
  5. isVersionCompatible(URL url)