Here you can find the source of getFile(URL resourceUrl, String description)
public static File getFile(URL resourceUrl, String description) throws FileNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; public class Main { public static final String URL_PROTOCOL_FILE = "file"; public static File getFile(URL resourceUrl, String description) throws FileNotFoundException { if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) { throw new FileNotFoundException(description + "->" + resourceUrl); }//from w w w . ja v a 2s. c o m try { return new File(toURI(resourceUrl).getSchemeSpecificPart()); } catch (URISyntaxException ex) { return new File(resourceUrl.getFile()); } } public static File getFile(URI resourceUri, String description) throws FileNotFoundException { if (!URL_PROTOCOL_FILE.equals(resourceUri.getScheme())) { throw new FileNotFoundException(description + "->" + resourceUri); } return new File(resourceUri.getSchemeSpecificPart()); } public static URI toURI(URL url) throws URISyntaxException { return toURI(url.toString()); } public static URI toURI(String location) throws URISyntaxException { return new URI(location.replaceAll(" ", "%20")); } }