Here you can find the source of toURL(String pathPrefix, String jar)
private static URL toURL(String pathPrefix, String jar)
//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); } } }