Java URL Create buildURL(String url)

Here you can find the source of buildURL(String url)

Description

Builds URL object with the specified URL string.

License

Open Source License

Parameter

Parameter Description
url the URL string.

Return

the URL object.

Declaration

public static URL buildURL(String url) 

Method Source Code

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

import java.net.MalformedURLException;
import java.net.URL;

public class Main {
    /**/*from w w w.j  a  v a 2  s .  c o  m*/
     * Builds URL object with the specified URL string.
     *
     * @param url the URL string.
     * @return the URL object.
     */
    public static URL buildURL(String url) {
        try {
            return new URL(url);
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException(e);
        }
    }

    /**
     * Builds URL object with the specified context and spec.
     *
     * @param context the context.
     * @param spec the spec.
     * @return the URL object.
     */
    public static URL buildURL(URL context, String spec) {
        try {
            return new URL(context, spec);
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException(e);
        }
    }
}

Related

  1. buildURL(String id)
  2. buildUrl(String repositoryUrl, String resourceUrl)
  3. buildURL(String spec)
  4. buildURL(String spec)
  5. buildURL(String spec, boolean trailingSlash)
  6. buildURL(String url)
  7. buildUrl(String url)
  8. buildUrl(String url, HashMap params)
  9. buildUrl(String URL, Map params)