我的测试包看起来像
test/
java/
com/
algos/
graphs/
GraphTest.java
resources/
graphs/
tinyG.txt
GraphTest
试读tinyG
如下_
@Test
public void testTinyG() throws IOException {
final Graph g = new Graph(getBufferedReaderFor("tinyG.txt"));
System.out.println(g.toString());
}
private static BufferedReader getBufferedReaderFor(final String filename) {
return new BufferedReader(new InputStreamReader(GraphTest.class.getResourceAsStream("/graphs/" + filename)));
}
它失败NullPointerException
了
GraphTest.class.getResourceAsStream("/graphs/" + filename)
返回null
。
我在这里做错了什么?
tinyG
有类似的数据
13
13
0 5
4 3
0 1
9 12
6 4
5 4
0 2
谢谢