Java Intellij-如何从插件jar加载文件

Java Intellij-如何从插件jar加载文件,java,intellij-idea,Java,Intellij Idea,我的资源文件夹中有一个属性文件。资源文件夹与src文件夹平行。从src文件夹中的一个类中,我需要在运行时加载属性文件的内容。我正在尝试以下代码: InputStream input = null; final Properties prop = new Properties(); VirtualFile file = VirtualFileManager.getInstance().findFileByUrl("./resources/" + propertiesFile); input = f

我的资源文件夹中有一个属性文件。资源文件夹与src文件夹平行。从src文件夹中的一个类中,我需要在运行时加载属性文件的内容。我正在尝试以下代码:

InputStream input = null;
final Properties prop = new Properties();
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl("./resources/" + propertiesFile);
input = file.getInputStream();
prop.load(input);
input.close();

但是“文件”总是空的。请您指出可能的错误。

您应该将(“./resources/”+…更改为(“../resources/”+…注意:在/resourcesadding两点之前的两个点而不是一个点没有任何区别…文件对象仍然为空