0
別のクラスのメソッドを呼び出そうとしているので、バッファライタに表示される可能性があります。私のコードは以下の通りです:BufferedWriterがJavaで書かれていない
public void Deposit(double amount) {
Bank bank = new Bank();
ArrayList<Client> customers = bank.getCustomers(); // Gets Customer Info from Bank
if (amount <= 0) {
System.err.println("You can not deposit that");
return;
} else {
checkInterest(0); // resets interest rates
amount = amount + amount * interest; //Applies interest to deposited amount
balance += amount; // Balance is == amount
System.out.println("You have deposited £" + amount + "Interest Rate of " + (interest * 100) + "%");
System.out.println("You now have a balance of £" + balance);
}
try {
FileWriter ac = new FileWriter("D:\\programming\\Java\\JavaBanking\\Transactions.txt", true);
BufferedWriter out = new BufferedWriter(ac);
String s = String.format("You have deposited the following amount:%n" + "£" + String.valueOf(amount) + "%nIn the account number:%n" +
getAccountNumber() + "%nAt: " + LocalDateTime.now() + "%nYour current balance is: £" + balance + "%n" + toString());
out.write(s);
//fw.write(t);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
BasicInfor-クライアントクラス `
public class Client {
private Object fullName;
private Account account;
public Client(String fullName, Account account) { // Passes in First Name and Account Type
// TODO Auto-generated constructor stub
this.fullName = fullName; // Creates Fields
this.account = account; // Adds account to Customers
}
}
public String BasicInfo() { //Return
return "FullName: " + fullName + "\n" +
account + "Sort Code :" + SortCode();
}
私はBufferwriterにappeaingクラスのクライアントからの基本情報方法を取得しようとしているが、何が起こるかはそれということですしています私がBasicInfoをバッファライタから取り出した場合、すべてが書き込まれ、メモに完全に表示されますが、何も追加しないと、txtファイルには表示されません。
。 –
バッファは何も実行しませんが、書き込みは1回しか実行されません。 –
コードが間違っていると思われます。私はあなたのデバッガのコードをステップ実行し、 's'の内容を確認します –