Here you can find the source of getResourceFile(String resource)
public static File getResourceFile(String resource)
//package com.java2s; import java.io.File; public class Main { private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory"; private static final String testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY); /** Try to discover the File for the test resource */ public static File getResourceFile(String resource) { File file = new File(resource); if (file.exists()) return file; file = new File(getTestResourcesDir() + "/" + resource); if (file.exists()) return file; String notSet = (getTestResourcesDir() == null ? " System property '" + SYSPROP_TEST_RESOURCES_DIRECTORY + "' not set." : ""); throw new IllegalArgumentException( "Cannot obtain '" + getTestResourcesDir() + "/" + resource + "'." + notSet); }//from w w w . j a v a 2 s . c o m public static String getTestResourcesDir() { return testResourcesDir; } }