java 读取properties配置文件代码如下:
String path = System.getProperty("user.dir") + "\\properties\\config.properties";
Properties pro = new Properties();
FileInputStream in = new FileInputStream(path);
pro.load(in);
System.out.println(pro.getProperty("driverPath"));
System.out.println(pro.getProperty("username"));
System.out.println(pro.getProperty("password"));
System.out.println(pro.getProperty("driver"));
System.out.println(pro.getProperty("url"));
System.out.println(pro.getProperty("user"));
System.out.println(pro.getProperty("mysql_password"));
in.close();
/// 保存属性到b.properties文件
FileOutputStream oFile = new FileOutputStream(path, false);// false表示覆盖原内容
pro.setProperty("url", "ssssssssssss");
pro.store(oFile, "The New properties file");
oFile.close();