Here you can find the source of getResourceAsFile(String resourceName)
public static File getResourceAsFile(String resourceName)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static File getResourceAsFile(String resourceName) { return new File(Thread.currentThread().getContextClassLoader().getResource(stripLeadingSlash(resourceName)) .getFile().replaceAll("%20", " ")); }//from ww w . j av a 2 s . c om private static String stripLeadingSlash(String resourceName) { return (resourceName.startsWith("/")) ? resourceName.substring(1) : resourceName; } }