⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configuration.java

📁 网上购物系统,相信看后会有很大收获,用java,jsp,servlet编写
💻 JAVA
字号:
package test;

import java.util.Properties;
import java.io.InputStream;
import java.io.IOException;

public class Configuration {
    private Properties properties;
    private final static Configuration cfg = new Configuration();//单子模型

    private Configuration() {
        properties = new Properties();
        InputStream is = null;
        try {
            is = getClass().getResourceAsStream("/ApplicationResources.properties");
            properties.load(is);
        } catch (Exception exception) {
          System.out.println("Can't read the properties file. ");
        } finally {
            try {
                if (is != null)
                    is.close();
            } catch (IOException exception) {
                // ignored
            }
        }
    }

    public static Configuration getInstance() {
      return cfg;
    }

    public String getValue(String key) {
        return properties.getProperty(key);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -