/**
* 获取配置文件中的设置字段
*
* @author yqzhilan
*
*/
public
class PropertyUtils {
static String propertiesdir = "connection.properties";
static Properties pros = new Properties();
public static Properties getProperties(String configPath) {
Properties pros = new Properties();
try {
ClassLoader cl = PropertyUtils.class.getClassLoader();
pros.load(cl.getResourceAsStream(configPath==null?propertiesdir:configPath.equals("")?propertiesdir:configPath));
} catch (IOException e) {
e.printStackTrace();
}
return pros;
}
public static void main(String[] args) {
Properties prop = PropertyUtils.getProperties("connection.properties");
System.out.println(prop.get("connecter.coin.username"));
}
}