我目前正在处理一个项目,在该项目中需要保存很多选项。
常规的选项保存方式是什么?
在保存/加载设置时,最佳实践是什么?
常规的选项保存方式是什么?
在保存/加载设置时,最佳实践是什么?
.properties
文件来存储配置,通常用于存储环境配置。如果这是你所说的内容,请参考 相关文档;以下是一个示例。String path = servletContext.getRealPath(propertiesFilePath);
Properties prop = new Properties();
try {
prop.load(new FileInputStream(path));
} catch (Exception e) {
// handle
}
String name = prop.getProperty("name");
String
的键/值对。 - Andrew Thompson