Java Path to URL toURL(String pathPrefix, String jar)

Here you can find the source of toURL(String pathPrefix, String jar)

Description

to URL

License

Open Source License

Declaration

private static URL toURL(String pathPrefix, String jar) 

Method Source Code


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

import java.io.File;

import java.net.MalformedURLException;

import java.net.URL;

public class Main {
    private static URL toURL(String pathPrefix, String jar) {
        try {//from  w  w w.  ja  v a  2  s . c  o m
            String path = jar.trim().replace(" ", "%20");
            if (!new File(path).isAbsolute())
                return new URL("file:" + pathPrefix + '/' + path);

            return new URL("file:" + path);
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. pathToURLs(String path)
  2. pathToURLs(String path)
  3. toTargetURL(String path)
  4. toUrl(final String path)
  5. toURL(String path)
  6. toURLs(String... paths)
  7. toURLs(String[] classPath)
  8. url(final String path)
  9. url(String path)