读取properties配置文件

import java.io.InputStream;

import java.util.Properties;

 

/**

 * 读取properties文件

 * 

 * @author 许琦

 * 

 */

public class PropUtils {

private static Properties prop=new Properties();

static{

InputStream in = null;

try {

in = ClassLoader.class.getResourceAsStream("/config.properites");

prop.load(in);

} catch (Exception e) {

e.printStackTrace();

System.out.println("加载配置文件出错");

}

}

public static String get(String propertyName) {

return prop.getProperty(propertyName);

}

 

}

你可能感兴趣的:(读取properties配置文件)