我有两个项目:Test1和Test2。Test2有一个脚本来测试项目文件夹:
this.getClass().getClassLoader().getResource("").getPath()
结果是:
/home/andy/Documents/Project/Test2/build/classes/
当Test2将Test1添加到编译时库中:
this.getClass().getClassLoader().getResource("").getPath()
结果为:
/home/andy/Documents/Project/Test1/build/classes/
所以我的问题是:
在将Test1添加到编译时库之后,为什么路径仍然不是
/home/andy/Documents/Project/Test2/build/classes/
?
getResource("fileProject1.txt")
。 - Thomas