在Java中存儲和加載應用程序級屬性的最佳方式是什麼?在Java桌面應用程序中加載應用程序屬性
有什麼simulare到.NET,我只想把東西在App.config
<appSettings>
<add key="emailAddress" value="[email protected]" />
</appSettings>
,然後檢索它像這樣:
string AdminEmail = ConfigurationManager.AppSettings["emailAddress"];
我必須加載屬性文件成文件流等?似乎是不必要的工作。
我已經試過這樣:
Properties props = new Properties();
FileInputStream fis = new FileInputStream("myProps.properties");
props.load(fis);
fis.close();
但是,這是給我一個java.io.FileNotFoundException異常。屬性文件需要與類相關的地方在哪裏?