📜  配置阅读器 java 代码示例

📅  最后修改于: 2022-03-11 14:52:47.259000             🧑  作者: Mango

代码示例1
public class ConfigurationReader {
private static Properties properties;
static {
 try (FileInputStream fileInputStream = new FileInputStream("configuration.properties")) {
            properties = new Properties();
            properties.load(fileInputStream);
 } catch (IOException e) {
            e.printStackTrace();
throw new RuntimeException("Unable to find configuration.properties file!");
        }
    }
public static String getProperty(String key) {
return properties.getProperty(key);