Here you can find the source of getUrlForLocalPath(String path)
public static URL getUrlForLocalPath(String path) throws IOException
//package com.java2s; /*//from w w w . j a va 2 s .c o m * This file is part of VirtualFile. * * Copyright 2016 by Bernd Riedl <bernd.riedl@gmail.com> * * Licensed under GNU Lesser General Public License 3.0 or later. * Some rights reserved. See COPYING, AUTHORS. */ import java.io.IOException; import java.net.URL; public class Main { public static URL getUrlForLocalPath(String path) throws IOException { return new URL(new java.io.File(path).toURI().toURL().toString() + (path.endsWith(java.io.File.separator) ? "/" : "")); } }