Java Path to URL getURL(String aPath)

Here you can find the source of getURL(String aPath)

Description

Returns a URL for given path.

License

Open Source License

Declaration

public static URL getURL(String aPath) 

Method Source Code


//package com.java2s;
import java.io.File;
import java.net.URL;

public class Main {
    /**//from  w  w w  .  j av  a  2s  .  com
     * Returns a URL for given path.
     */
    public static URL getURL(String aPath) {
        try {
            return getFile(aPath).toURI().toURL();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Returns a File for given path.
     */
    public static File getFile(String aPath) {
        return new File(aPath);
    }
}

Related

  1. fileToURIString(File file)
  2. getUri(String baseApiUrl, String path)
  3. getUriNormalizedContainerAndPathWithoutSlash(String stringUriValue, String containerUrl, boolean normalizeUrlMode, boolean matchBaseUrlMode)
  4. getUrl(String baseUrl, String absPath)
  5. getURL(String host, int port, String path, boolean isHTTPS)
  6. getUrl(String inPath)
  7. getUrl(String ip, String port, String servicePath, String serviceName, String... args)