Java URL from newUrl(String href)

Here you can find the source of newUrl(String href)

Description

Creates a new URL and wraps the java.net.MalformedURLException around an IllegalArgumentException if one was thrown.

License

Open Source License

Parameter

Parameter Description
href The data of the URL

Exception

Parameter Description
IllegalArgumentException If a MalformedURLException was thrown

Return

A new URL

Declaration

public static URL newUrl(String href) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.*;

public class Main {
    /**/*  www .  j ava2s .  c o m*/
     * Creates a new URL and wraps the {@link java.net.MalformedURLException} around an IllegalArgumentException if one
     * was thrown.
     *
     * @param href The data of the URL
     * @return A new URL
     * @throws IllegalArgumentException If a MalformedURLException was thrown
     */
    public static URL newUrl(String href) {
        try {
            return new URL(href);
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("Malformed URL: " + href, e);
        }
    }
}

Related

  1. makeUrl(String url)
  2. makeURL(String url)
  3. makeURL(String urlstr)
  4. makeURL(String[] URLStrings)
  5. newURL(CharSequence urlString)
  6. newURL(String location)
  7. newURL(String url)
  8. newURL(String url_name)
  9. newUrl(String urlString)