public class ConfigManager { //读取配置文件的工具类,单例模式 private static ConfigManager configManager; private static Properties properties; private ConfigManager() { //必须以private修饰 String configFile = "database.properties"; properties = new Properties(); InputStream is = ConfigManager.class.getClassLoader().getResourceAsStream(configFile); try { properties.load(is); is.close(); } catch (IOException e) { e.printStackTrace(); } }
添加回答
举报
0/150
提交
取消