时间:2021-07-01 10:21:17 帮助过:56人阅读
//第一种方式
Properties prop= new Properties();
//读取文件 通过类加载读取
InputStream is = JDBCUtils.class.getClassLoader().getResourceAsStream("data.properties");
prop.load(is);
String driverClass = prop.getProperty("driverClass");
String url = prop.getProperty("url");
String username = prop.getProperty("username");
String password = prop.getProperty("password");
//第二种方式
Properties properties = new Properties();
// 读取属性文件:使用Java中Properties的对象.
InputStream is = new FileInputStream("src/jdbc.properties");
properties = new Properties();
properties.load(is);
String driverClass = properties.getProperty("driverClass");
String url = properties.getProperty("url");
String username = properties.getProperty("username");
String password = properties.getProperty("password");
JDBCUtils工具类配置文件的读取方式
标签:cut bsp source get 配置 use 对象 inpu 文件的