public static File getFileForResource(final String resourcePath) {
        URL path = ResourceUtil.class.getResource(resourcePath);
        if (path == null) {
            path = ResourceUtil.class.getResource("/");
            return new File(new File(path.getPath()), resourcePath);
        }

        return new File(path.getPath());
    }
public static File getFileForResource ( final String resourcePath ) { URL path = ResourceUtil . class . getResource ( resourcePath ) ; if ( path == null ) { path = ResourceUtil . class . getResource ( "/" ) ; return new File ( new File ( path . getPath ( ) ) , resourcePath ) ; } return new File ( path . getPath ( ) ) ; }
Convert a resource path to a File object.

@param resourcePath The resource-relative path to resolve.
@return A file instance representing the resource in question.