请采纳.
// 项目所在路径
File path1 = new File("").getCanonicalFile();
// 编译后项目所在路径
String path2 = URLDecoder.decode(App.class.getResource("/").getPath(), "utf-8").substring(1);
// 查询 当前项目根目录的父级 下的名为 images 文件
File[] pFile = path1.getParentFile().listFiles();
File py = Arrays.stream(pFile).filter(file -> file.getName().equals("images")).findFirst().orElse(null);
System.out.println(py);