在我的StockTransaction.java中,首先运行
try{
FileOutputStream fos = new FileOutputStream("C:"+File.separatorChar+"transactions.dat");
OutputStreamWriter osw = new OutputStreamWriter(fos);
BufferedWriter writer = new BufferedWriter(osw);
writer.append(aStockTransaction.toString());
writer.append("******This Transaction ends Here.*****");
writer.flush();
writer.close();}
Run Code Online (Sandbox Code Playgroud)
然后在我的brokerageAccount.java中,这最后运行
try {
FileOutputStream fos = new FileOutputStream("C:"+File.separatorChar+"transactions.dat");
OutputStreamWriter osw = new OutputStreamWriter(fos);
BufferedWriter writer = new BufferedWriter(osw);
writer.append(brokerageAcc1.toString());
writer.append("******This is end of File*****");
writer.flush();
writer.close();
//System.out.println(brokerageAcc1.toString());
}
Run Code Online (Sandbox Code Playgroud)
我用System.out.println测试了控制台,输出很好.但是结束文件只显示brokerAcc1.toString(),对于aStockTransaction.toString()没有任何内容.为什么?怎么解决?提前致谢!
| 归档时间: |
|
| 查看次数: |
100 次 |
| 最近记录: |