PropertiesUtil2

package com.msmiles.lottery.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;

public class PropertiesUtil {
	static Properties prop = new Properties();

	private PropertiesUtil(){
		
	}
	public PropertiesUtil(String filePath){
		try {
			InputStream in = PropertiesUtil.class.getResourceAsStream(filePath);
			prop.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public Enumeration<?> getKey() {
		return prop.propertyNames();
	}

	public String getValue(String key) {

		return prop.getProperty(key);
	}

	public String getValue(RegexEnum key) {
		return prop.getProperty(key.toString());
	}

	public String getValue(DBEnum key) {
		return prop.getProperty(key.toString());
	}

}

   文件路径与类所在目录相同

你可能感兴趣的:(properties)