Here you can find the source of getResourceAsFile(String relativePath)
public static File getResourceAsFile(String relativePath) throws URISyntaxException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.net.URISyntaxException; import java.net.URL; public class Main { public static File getResourceAsFile(String relativePath) throws URISyntaxException { URL url = Thread.currentThread().getContextClassLoader() .getResource(relativePath); File file = new File(url.toURI()); return file; }/*from www . j a v a 2 s.c o m*/ }