public class ResourceUtil { /** * 获取resources路径下的文件路径 * * @param filePath 若文件路径为“E:\Code\UiAuto\boos\src\main\resources\driver\chromedriver.exe” 则仅传“driver\chromedriver.exe”即可 * @return */ public static String getPath(String filePath) { return Thread.currentThread().getContextClassLoader().getResource("").getPath() + filePath; } }