Here you can find the source of getFileFromPath(Object obj, String fileName)
private static File getFileFromPath(Object obj, String fileName)
//package com.java2s; //License from project: Apache License import java.io.File; import java.net.URL; public class Main { private static File getFileFromPath(Object obj, String fileName) { ClassLoader classLoader = obj.getClass().getClassLoader(); URL resource = classLoader.getResource(fileName); return new File(resource.getPath()); }//from w ww . ja va 2 s . c o m }