package baseTest;
import java.io.IOException;
import java.io.InputStream;import java.util.Properties;//读取配置文件public class ConfigManager { private static ConfigManager config; private static Properties pro; //构造方法进行配置文件读取 private ConfigManager(){ String configFile="database.properties"; pro=new Properties(); InputStream in=ConfigManager.class.getClassLoader().getResourceAsStream(configFile); try { pro.load(in); in.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } //通过单列模式设置实力化个数 public static ConfigManager getInstance(){ if(config==null){ config=new ConfigManager(); } return config; } //通过key获取对应的value public String getString(String key){ return pro.getProperty(key); }}