Java Resource Load getResourceFile(Class clazz, String path)

Here you can find the source of getResourceFile(Class clazz, String path)

Description

Get resource File corresponding to a given path in clazz package

License

Open Source License

Parameter

Parameter Description
path ex : "/config/cnig_PLU_2014/files.xml"

Declaration

public static File getResourceFile(Class<?> clazz, String path) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**/*w  ww. j  a v  a2s  .c  o m*/
     * Get resource File corresponding to a given path in clazz package
     * 
     * @param path ex : "/config/cnig_PLU_2014/files.xml"
     * @return
     */
    public static File getResourceFile(Class<?> clazz, String path) {
        try {
            return new File(clazz.getResource(path).getPath());
        } catch (NullPointerException e) {
            throw new RuntimeException("Resource '" + path + "' not found");
        }
    }
}

Related

  1. getResourceBundle(String resourceURI, Locale targetLocale)
  2. getResourceBundleForLoc(String language, String fileName)
  3. getResourceBytes(String path)
  4. getResourceByZip(final ZipInputStream zipIN, final String resourcePath)
  5. getResourceDirectory()
  6. getResourceFile(Class theClass, String fileName)
  7. getResourceFile(String relativeResourceFilePathname)
  8. getResourceFile(String resource)
  9. getResourceFile(String resourceName)