propertyreader.java

来自「一个java 代码生成器」· Java 代码 · 共 68 行

JAVA
68
字号
/**
 * Copyright (c) 2002, Siddhartha P. Chandurkar siddhartha@visioncodified.com
 * All rights reserved.
 * Licensed under the Academic Free License version 1.1
 * See the file LICENSE.TXT for details.
 * LICENSE.txt is located in the directory  <install-directory>\Jenerator
 * of your Jenertaor Installation.
 *
 */

package com.jenerator.util;


//<Imports>

import org.apache.log4j.Logger;

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

//</Imports>

/**
 * PropertyReader
 * This class is a utility class using which one can read any Property file.
 *
 * @author Siddhartha P. Chandurkar
 * @version 0.9.0
 */
public class PropertyReader {


    //ATTRIBUTES
    private String fileName;
    private static Logger log = Logger.getLogger(com.jenerator.util.PropertyReader.class.getName());
    private Properties props;

    //CONSTRUCTORS
    public PropertyReader(String _fileName) throws ConfigurationException {
        fileName = _fileName;
        props = new Sql2JavaMapping();
        readPropertyFile();
    }

    //METHODS
    private void readPropertyFile() throws ConfigurationException {
        try {
            props.load(new FileInputStream(fileName));
        } catch (IOException e) {
            log.fatal(e);
            throw new ConfigurationException(e);
        }
    }

    public Properties getProperties() {
        return props;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
}

⌨️ 快捷键说明

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