Java Resource Path Get getPathOfResource(Class clazz, String fileName)

Here you can find the source of getPathOfResource(Class clazz, String fileName)

Description

get Path Of Resource

License

Open Source License

Declaration

public static String getPathOfResource(Class<?> clazz, String fileName) 

Method Source Code

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

import java.net.URL;

public class Main {
    public static String getPathOfResource(Class<?> clazz, String fileName) {
        URL url = getUrlAsResource(clazz, fileName);
        if (url == null)
            return null;
        return url.getPath();
    }//from   ww w .  j  a  va2 s  .c  o  m

    public static URL getUrlAsResource(Class<?> clazz, String fileName) {
        URL url = clazz.getResource(fileName);
        return url;
    }
}

Related

  1. getExistingResourceAsFile(final String resourcePath)
  2. getFileFromBundle(String bundleName, String resourcePath)
  3. getFileFromResource(Class clazz, String path)
  4. getFileResourcePaths(final Class clazz, final String fileNameRegex)
  5. getPath(final Object resource)
  6. getPluginResource(Bundle bundle, String resourcePath)
  7. getRelativeResource(Class clazz, String relativePath)
  8. getResource(Class cl, String path)
  9. getResource(final Class baseClass, final String path)