Here you can find the source of getAlternateResourceFile(final String resourcePath)
public static File getAlternateResourceFile(final String resourcePath)
//package com.java2s; //License from project: Apache License import java.io.File; import java.net.URI; import java.net.URISyntaxException; public class Main { /**/* ww w . j a va 2s .com*/ * A configurable, alternate location to search for resources, if not found in the classpath. */ public static File alternateResourceRootFolder = null; public static File getAlternateResourceFile(final String resourcePath) { return getResourceFileRelativeToBase(alternateResourceRootFolder, resourcePath); } public static File getResourceFileRelativeToBase(final File baseDir, final String resourcePath) { final String baseDirUriString = baseDir != null ? baseDir.toURI().toString() : "file:/"; final boolean baseEndsWithSlash = baseDirUriString.endsWith("/"); final boolean resourcePathBeginsWithSlash = resourcePath.startsWith("/"); final String uriString; if (baseEndsWithSlash != resourcePathBeginsWithSlash) { uriString = baseDirUriString + resourcePath; } else if (baseEndsWithSlash) { uriString = baseDirUriString.substring(0, baseDirUriString.length() - 1) + resourcePath; } else { uriString = baseDirUriString + "/" + resourcePath; } try { File f = new File(new URI(uriString)); return f; } catch (URISyntaxException e) { e.printStackTrace(); return null; } } }