Java Resource Path Get getResourceFilePath(String name)

Here you can find the source of getResourceFilePath(String name)

Description

get Resource File Path

License

Open Source License

Declaration

public static String getResourceFilePath(String name) 

Method Source Code


//package com.java2s;
import java.net.URL;

public class Main {
    public static String getResourceFilePath(String name) {
        ClassLoader loader = ClassLoader.getSystemClassLoader();
        URL url = loader.getResource(name);
        if (url == null) {
            throw new RuntimeException("File does not exist: " + name);
        }//from w w  w.java2  s  .  c om
        return url.getFile();
    }
}

Related

  1. getResourceAsStream(String resourcePath, ClassLoader classLoader, Class clazz)
  2. getResourceAsString(String path)
  3. getResourceFile(Class clazz, String relPath)
  4. getResourceFile(final Class baseClass, final String path)
  5. getResourceFile(String sResourcePath, Class cRefClass)
  6. getResourceFileRelativeToBase(final File baseDir, final String resourcePath)
  7. getResourceListing(Class clazz, String path)
  8. getResourceListing(Class clazz, String path)
  9. getResourceListing(Class clazz, String path)