Here you can find the source of getResourceFile(Class clazz, String fileName)
public static File getResourceFile(Class clazz, String fileName) throws IOException, URISyntaxException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; public class Main { public static File getResourceFile(Class clazz, String fileName) throws IOException, URISyntaxException { ClassLoader classLoader = clazz.getClassLoader(); URL resource = classLoader.getResource(fileName); if (resource == null) throw new FileNotFoundException(fileName + " not found"); return new File(resource.toURI()); }/* w w w. j a v a 2s. co m*/ }