1
繼簡單的ini4j教程後,我寫了一個類來讀寫JDBC連接。 下面是當點擊該對話框按鈕我做的:ini4j商店不工作
public void actionPerformed(ActionEvent ae){
JButton b = (JButton)ae.getSource();
if (b == save || b == load) {
try {
Ini ini;
String section = name.getText();
if (b == load) {
System.out.println("Loading " + section);
ini = new Ini(new File(cfgname));
driver.setText(ini.get(section, "Driver"));
url.setText(ini.get(section, "URL"));
username.setText(ini.get(section, "User"));
password.setText(ini.get(section, "Password"));
} else {
System.out.println("Saving " + section);
ini = new Ini(new File(cfgname));
ini.put(section, "Driver", driver.getText());
ini.put(section, "URL", url.getText());
ini.put(section, "User", username.getText());
ini.put(section, "Password", password.getPassword());
ini.store();
} // endif b
} catch (FileNotFoundException fe) {
System.out.println(cfgname + ": not found " + fe);
setVisible(false);
} catch (IOException ioe) {
System.out.println(ioe);
setVisible(false);
} // end try/catch
} else {
id = (ae.getSource() == ok);
setVisible(false);
} // endif b
} //中的actionPerformed
結束閱讀效果很好,但打「保存」的時候寫執行以下操作:
新科和值寫入內存(我可以重新加載它們) 但文件沒有更新,並保持不變。
我錯過了什麼?