Here you can find the source of getFile(Class> cls, String resource)
public static File getFile(Class<?> cls, String resource) throws IOException
//package com.java2s; import java.io.*; import java.net.URL; public class Main { public static File getFile(Class<?> cls, String resource) throws IOException { URL url = cls.getResource(resource); if (url == null) return null; return new File(url.getFile()); }/*from w ww . j a v a2 s . co m*/ }