java web工程中读取properties文件,路径一直不知道怎么写
properties文件放在WEB-INF\config\uas-system.properties
我的代码是:
//根据key读取value
public static String readValue(String key) {
Properties props = new Properties();
try {
InputStream in = new BufferedInputStream(new FileInputStream("/uas-operation.properties"));
props.load(in);
String value = props.getProperty(key);
System.out.println(key + value);
return value;
} catch (Exception e) {
e.printStackTrace();
return "";
}