maintainproperties.java

来自「javaBB,一套很不錯的JSP源碼,特共享給大家」· Java 代码 · 共 40 行

JAVA
40
字号
package org.javabb.infra;

import java.io.FileInputStream;
import java.util.Properties;

/**
 * @author Dalton Camargo - <a href="mailto:dalton@ag2.com.br">dalton@ag2.com.br</a> <Br>
 * AG2 - Agencia de Inteligencia Digital S.A.<Br>
 * <a href="http://www.ag2.com.br">http://www.ag2.com.br</a><Br>
 * Nosso <i>www</i> e mais <b>inteligente</b>!
 */
public class MaintainProperties {
    private FileInputStream localFile = null;
    private Properties properties = null;
    
    
    public MaintainProperties(FileInputStream file) throws Exception{
        localFile = file;
        loadProperties();
    }
    
    private void loadProperties() throws Exception{
        if(localFile == null){
            throw new Exception("Property is null: FileInputStream !");
        }
        properties = new Properties();
        properties.load(localFile);
    }
    
    public String getProperty(String nmProperty) throws Exception{
        if(properties == null){
            throw new Exception("Property is null !");
        }
        if(nmProperty == null) {
            return null;
        }
        return properties.getProperty(nmProperty);
    }
}

⌨️ 快捷键说明

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