读取web项目文件的时候,可以先切换到Navigator(myeclipse)视图,然后找到你需要读取的文件。例如我的文件是在WebRoot --->WEB-INF ---> a.properties。
那么我们可以
String path = System.getProperty("webapp.root")
+ "WEB-INF" + File.separator + "classes" + File.separator + "a.properties";
path就是你的文件在该项目的地址了。
System.setProperty("source.path", path);
你就可以在别的地方 根据
System.getProperty("source.path")
获取到你的文件路径。