如何知道resourceBoundle加载的属性的绝对路径

fea*_*lfu 5 java tomcat

我正在使用以下代码加载属性:

ResourceBoundle boundle = ResourceBundle.getBundle("file")
Run Code Online (Sandbox Code Playgroud)

我想知道加载文件的绝对路径.例如,如果我在tomcat的webapps文件夹中的Web应用程序中执行此代码,我想获取:

c:\tomcat8\webapps\example\WEB-INF\classes\file.properties.
Run Code Online (Sandbox Code Playgroud)

我怎么知道这条路?

fea*_*lfu 0

我已经通过这篇文章“获取当前工作目录” “解决”了我的问题。对于我的问题,我只需要这个,一旦我知道工作目录,我就可以找到绝对路径

public class Test {
public static void main(String... args) throws Exception {
    URL location = Test.class.getProtectionDomain().getCodeSource().getLocation();
    System.out.println(location.getFile());
}}
Run Code Online (Sandbox Code Playgroud)

我想也许这个解决方案并不能涵盖所有的情况,但是对我来说已经足够了。