如何在不提供完整路径名的情况下从 intelliJ IDEA 中的资源文件夹访问图像

How to access images from a resource folder in intelliJ IDEA without having to give entire path name

我如何在 intelliJ IDEA 中做这样的事情

File file = new File("C:\Users\Account\Documents\ProjectFolder\ResourceFolder\image");

但不必输入整个文件路径。我很确定有办法,而且我很确定它与将它添加到我的构建路径有关。我知道如何在 Eclipse 中执行此操作,但在 intelliJ 中不知道。
提前致谢!

您应该使用Java 资源加载系统。这与您的 IDE 无关。一旦你有 marked a folder as resource folder in IntelliJ, it is available in your code as via resource loader.