【发布时间】:2015-06-08 08:30:52
【问题描述】:
对于单元测试,我想以编程方式从“values”文件夹中打开 colors.xml 和 strings.xml,以便将条目与其他文件中的条目进行比较。 我尝试过这样的事情:
String fileName = "res/strings.xml";
ClassLoader classLoader = getClass().getClassLoader();
File f = new File(classLoader.getResource(fileName).getFile());
if(f.exists()) {
System.out.println("OK");
} else {
System.out.println("not OK");
}
Assert.assertNotNull(f);
它不起作用 - “不正常”。
【问题讨论】: