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: Apache 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) throws FileNotFoundException { return getFile(resourceUrl, "URL"); }/*from ww w . j a va2s . c o m*/ public static File getFile(URL resourceUrl, String description) throws FileNotFoundException { if (resourceUrl == null) { throw new IllegalArgumentException("Resource URL must not be null"); } if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) { throw new FileNotFoundException(description + " cannot be resolved to absolute file path " + "because it does not reside in the file system: " + resourceUrl); } try { return new File(toURI(resourceUrl).getSchemeSpecificPart()); } catch (URISyntaxException ex) { // Fallback for URLs that are not valid URIs (should hardly ever happen). return new File(resourceUrl.getFile()); } } public static URI toURI(URL url) throws URISyntaxException { return toURI(url.toString()); } public static URI toURI(String location) throws URISyntaxException { return new URI(location.replace(" ", "%20")); } }