ArrayLists の textfield を介して入力データを保存し、ファイルに保存するこのボタンがあります。
private void btnSaveAActionPerformed(java.awt.event.ActionEvent evt) {
BankAccount account = new BankAccount();
ButtonGroup bg = new ButtonGroup();
bg.add(rad_savings);
bg.add(rad_checking);
account.setAccountName(txt_accountname.getText());
account.setAccountNo(txt_accountnumber.getText());
list.add(account);
String fileName = "bank.txt";
FileWriter file = null;
try {
file = new FileWriter(fileName,true);
PrintWriter pw = new PrintWriter(file);
for(BankAccount str: list) {
pw.println(str);
}
pw.flush();
pw.println("\n");
} catch(FileNotFoundException ex) {
JOptionPane.showMessageDialog(this, "Can't create your account!");
} catch (IOException ex) {
Logger.getLogger(JFrameNewAccount.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
file.close();
} catch (IOException ex) {
Logger.getLogger(JFrameNewAccount.class.getName()).log(Level.SEVERE, null, ex);
}
}
Withdraw_AccountName と Withdraw_AccountNumber のテキスト フィールドもありますが、配列リスト内の口座番号を検索するにはどうすればよいですか? Withdraw_AccountNumber が arraylists の口座番号と一致すると、Withdraw_AccountName に口座名も表示されます。助けてください。