如何检查 war 文件中是否存在某个文件?我知道我可以使用
boolean doesExist = new File(myfile).exists();
但是我如何在 war 中的java类中使用它呢? file.getAbsolutePath() 仅显示 war 文件运行的位置。我需要检查 war 中的另一个目录中是否有与 war 中的文件名匹配的图像,以便我可以显示该图像或通用图像(如果不存在)。
最佳答案
ServletContext.getResource()
来自javadoc:
This method returns null if no resource is mapped to the pathname.
关于java - 如何检查war文件中的文件是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2059006/