public void test()
{
//classes\spring\db-config.properties
/*
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:zwf
jdbc.username=11
jdbc.password=11
*/
InputStream in = SysApplicationListener.class.getResourceAsStream("/spring/db-config.properties");
Properties p = new Properties();
try
{
p.load(in);
String driverClassName = p.getProperty("jdbc.driverClassName");
String url = p.getProperty("jdbc.url");
String username = p.getProperty("jdbc.username");
String password = p.getProperty("jdbc.password");
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void test()
{
//classes\spring\db-config.properties
/*
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:zwf
jdbc.username=11
jdbc.password=11
*/
try
{
String path = SysApplicationListener.class.getResource("/spring/db-config.properties").getPath();
System.out.println(path);
// InputStream in = SysApplicationListener.class.getResourceAsStream("/spring/db-config.properties");
InputStream in = new BufferedInputStream(new FileInputStream(path));
Properties p = new Properties();
//
p.load(in);
in.close();
//
String driverClassName = p.getProperty("jdbc.driverClassName");
String url = p.getProperty("jdbc.url");
String username = p.getProperty("jdbc.username");
String password = p.getProperty("jdbc.password");
String isUpdate = p.getProperty("isUpdate");
//
System.out.println(driverClassName);
System.out.println(url);
System.out.println(username);
System.out.println(password);
System.out.println(isUpdate);
//
if (isUpdate != null && isUpdate.equals("0"))
{
// String path = SysApplicationListener.class.getResource("/spring/db-config.properties").getPath();
FileOutputStream out = new FileOutputStream(path);
p.put("isUpdate", "1");
p.store(out, "so boring. zengwenfeng.update");
out.close();
out.flush();
//
System.out.println("ok!");
}
}
catch (IOException e)
{
e.printStackTrace();
}
}