【发布时间】:2016-09-08 13:54:09
【问题描述】:
在我的 Java 应用程序中,我有一个属性类(如下所示)。此类引用 Linux 服务器上的 application.properties 文件。
输入文件路径的正确格式是什么,我需要转义字符吗?
当前属性类:
**
* Properties class used to obtain properties from the
* application.properties file
*/
public class MyProperties {
private static Properties props = new Properties();
static {
try {
//path to file on server
java.io.InputStream in= new FileInputStream("/path/to/file/application.properties");
props.load(in);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Returns a given property by its key
* @param key
* @return
*/
public static String getProperty(String key) {
return props.getProperty(key);
}
}
我应该使用://path//to//file//application.properties 而不是我当前的实现吗?
【问题讨论】:
标签: java linux properties escaping filepath