Here you can find the source of toTargetURL(String path)
public static URL toTargetURL(String path) throws MalformedURLException
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 import java.io.File; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; public class Main { private static File basedir; private static URI baseURI; public static URL toTargetURL(String path) throws MalformedURLException { return getBaseURI().resolve("target/" + path).toURL(); }/*from w w w. j a v a 2 s.c o m*/ public static URI getBaseURI() { if (baseURI == null) { getBasedir(); } return baseURI; } public static File getBasedir() { if (basedir == null) { String cwd = System.getProperty("basedir"); if (cwd == null) { // System property not set. // Use CWD. cwd = System.getProperty("user.dir"); basedir = new File(cwd); // Set the System property. System.setProperty("basedir", basedir.getAbsolutePath()); } else { // Has system property, use it. basedir = new File(cwd); } baseURI = basedir.toURI(); } return basedir; } }