我的项目结构看起来像
project/
src/main/
java/ ...
resources/
definitions.txt
test/
CurrentTest.java
resources/ ...
在我的测试中,我需要打开 definitions.txt
我做
@Test
public void testReadDesiredDefinitions() throws PersistenceException, IOException {
final Properties definitions = new Properties();
definitions.load(new ResourceService("/").getStream("desiredDefinitions"));
System.out.println(definitions);
}
当我跑这个时,我明白了
java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:418)
at java.util.Properties.load0(Properties.java:337)
at java.util.Properties.load(Properties.java:325)
我该如何阅读此文本文件?
谢谢