Here you can find the source of getResourcePath(Class> c, String name)
public static String getResourcePath(Class<?> c, String name)
//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(); } }