Here you can find the source of getFile(URL aURL)
public static File getFile(URL aURL)
//package com.java2s; import java.io.*; import java.net.*; public class Main { /**/*from w w w . j av a 2 s. c om*/ * Returns the URL as a file. */ public static File getFile(URL aURL) { // If "jar:" url, recast as inner URL if (aURL.getProtocol().equals("jar")) { String urls = aURL.toExternalForm(); int sep = urls.indexOf('!'); urls = urls.substring(4, sep); try { aURL = new URL(urls); } catch (Exception e) { throw new RuntimeException(e); } } // Return file for URL String path = aURL.getPath(); try { path = URLDecoder.decode(path, "UTF-8"); } catch (Exception e) { throw new RuntimeException(e); } return isLocal(aURL) ? new File(path) : null; } /** * Returns whether a URL is local. */ public static boolean isLocal(URL aURL) { String url = aURL.toExternalForm().toLowerCase(); return url.startsWith("file:") || url.startsWith("jar:file:"); } }