保存设置的最佳做法?

wed*_*rer 3 java application-settings

我目前正在开发一个项目,其中应该保存许多选项.

  • 通常如何保存选项?
  • 保存/加载设置时的最佳做法是什么?

Alb*_*gni 6

您可以使用.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"); 
Run Code Online (Sandbox Code Playgroud)