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; } }
原创文章,作者:端木书台,如若转载,请注明出处:https://blog.ytso.com/272701.html