Java Resource Load getResourcePath(Class c, String name)

Here you can find the source of getResourcePath(Class c, String name)

Description

Get resource in test scope for some class.

License

Open Source License

Declaration

public static String getResourcePath(Class<?> c, String name) 

Method Source Code


//package com.java2s;

import java.io.File;

public class Main {
    private static String baseResourcePath = new StringBuilder().append("src").append(File.separator).append("test")
            .append(File.separator).append("resources").append(File.separator).toString();

    /**//w w  w  .j a  v  a 2s  . com
     * Get resource in test scope for some class.
     * Example: class org.test.MyTest and name "my_resource.txt" returns "src/test/resource/org/test/my_resource.txt"
     */
    public static String getResourcePath(Class<?> c, String name) {
        return new StringBuilder().append(baseResourcePath)
                .append(c.getPackage().getName().replace('.', File.separatorChar)).append(File.separator)
                .append(name).toString();
    }
}

Related

  1. getResourceNameFromFileName(final String pFileName)
  2. getResourceNames(File dir)
  3. getResourceNames(String resName)
  4. getResourceNamesFromDir(File dir, String extension)
  5. getResourcePath()
  6. getResourceReader(final String aResName)
  7. getResources(File root, File path, Vector result)
  8. getResources(final Pattern pattern)
  9. getResourceScripts(String path)