public void init() {
//建立到属性文件的流
InputStream is = getClass().getResourceAsStream("./dbconfig.properties");
Properties dbProps = new Properties();
try {
//通过流读取属性文件
dbProps.load(is);
is.close();//关闭流
}
catch (Exception e) {
System.err.println("不能读取属性文件. " +
"请确保db.properties在CLASSPATH指定的路径中");
return;
}finally{
is = null;
}
//其他对属性文件的操作
}
//建立到属性文件的流
InputStream is = getClass().getResourceAsStream("./dbconfig.properties");
Properties dbProps = new Properties();
try {
//通过流读取属性文件
dbProps.load(is);
is.close();//关闭流
}
catch (Exception e) {
System.err.println("不能读取属性文件. " +
"请确保db.properties在CLASSPATH指定的路径中");
return;
}finally{
is = null;
}
//其他对属性文件的操作
}
{
String strPath = ClassLoader.getSystemResource ("test/iniTest.ini").toString ().substring (6);
try
{
FileOutputStream outStream = new FileOutputStream (strPath);
iniFileP.setProperty("MailPort", "88");
iniFileP.save (new FileOutputStream (strPath), "head");
}
catch (Exception e)
{
System.out.println (e.toString ());
}
}