Here you can find the source of url(String path)
public static URL url(String path) throws MalformedURLException
//package com.java2s; //License from project: Open Source License import java.net.MalformedURLException; import java.net.URL; public class Main { public static URL url(String path) throws MalformedURLException { //Starts with double backslash, is likely a UNC path if (path.startsWith("\\\\")) { path = path.replace("\\", "/"); }//w ww .j a v a2s . co m return new URL("file:/" + (path.startsWith("/") ? "/" + path : path)); } }