在我的web應用程序中,我使用web文件夾內的屬性文件,並且需要從同一應用程序中的java文件中引用屬性文件以獲取屬性的值。我如何提供路徑?我需要路徑名稱而不是URI。我的代碼如下:如何獲取運行時Web應用程序路徑?
Properties prop = new Properties();
FileInputStream propertiesStream = null;
try {
propertiesStream = new FileInputStream("..\Files\Prop.properties");
prop = new Properties();
prop.load(propertiesStream);
prop.getProperty("id");
propertiesStream.close();
} catch (IOException ioException) {
System.out.println("PropertiesLoader IOException message:" + ioException.getMessage());
}
你能解釋一下你的意思是什麼
你可以用下面的代碼獲取它「參考」?你的意思是一個文件路徑或URL? – Zeemee 2011-03-22 10:42:24