public static File getFileFromURL(URL url) { File file; String filename = getFilePathFromUrl(url); if (filename.equals("")) { file = null; } else { file = new File(filename); } return file; }
/** * Retrieves the total path of a resource from the Thread Context. * * @param resource the resource name to be retrieved. * @return the decoded path. */ public static String getResourcePathFromContext(String resource) { URL url = Thread.currentThread().getContextClassLoader().getResource(resource); return getFilePathFromUrl(url); }