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

📄 configuration.java

📁 着重用css实现页面显示功能,实现简单数据库连接,是很好的入门教程
💻 JAVA
字号:
/*
 * Created on 2006-1-19
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package cn.com.aheadsoft.conndb;

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

/**
 * @author baoyabin
 * @version 1.0
 */
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("/connect.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
                    }
            }
    }

    /**
     * Use singleton pattern, only return one instance of Configuration.
     * @return Configuration
     */
    public static Configuration getInstance() {
            return cfg;
    }

    /**
     * Retun a value for certain key.
     * @param key a certain key define in properties file.
     * @return value
     */
    public String getValue(String key) {
            return properties.getProperty(key);
    }
}

⌨️ 快捷键说明

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