大家好,我的BufferedWriter一直有問題。起初,我只有1名緩衝作家被表現爲cc
1和這個工作完美地與輸出一起,但現在,我已經嘗試實現2我繼續得到一個錯誤別的地方Java - 兩位緩衝作家
Multiple markers at this line
- Syntax error, insert "}" to complete Statement
- Syntax error, insert "Finally" to complete
這裏是碼。在沒有的情況下 - 錯誤在}else if (command.equals("action 2"))
線
if (selected) {
if (command.equals("action1")) {
BufferedWriter aa;
try {
File writerB = new File("output1.txt"); //set transaction-list.txt to be the destination file when writeTransactions is used
if (!writerB.exists()) {
writerB.createNewFile();
}
FileWriter bb = new FileWriter(writeBalance, true); //filewriter
aa = new BufferedWriter(bb); // bufferedwriter
BufferedWriter cc;
try {
int x=0;
File writerT = new File("output2.txt"); //set transaction-list.txt to be the destination file when writeTransactions is used
if (!writerT.exists()) {
writerT.createNewFile();
}
FileWriter dd = new FileWriter(writeTransactions, true); //filewriter
cc = new BufferedWriter(dd); // bufferedwriter
String newLine = System.getProperty("line.separator"); //creates a line separator which will be used with string newLine
if (n==0) {
bw.write(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(now) + newLine);
wb.write(c);}
bw.close;
wb.close}
}else if (command.equals("action 2"))
請格式化您的代碼以便於閱讀!另外,這個代碼之後是什麼? – meskobalazs
這是2015年,所以請使用java.nio.file(例如:你不檢查File.createNewFile()')的結果。請參閱[這裏](http://java7fs.wikia.com/wiki/Using_the_java.nio.file_API)和[這裏](http://java7fs.wikia.com/wiki/Why_File_sucks)。 – fge
我強烈建議您正確縮進代碼(大多數IDE都有一個用於此的菜單選項)。這會幫助你看到你有一個無與倫比的'{'以及幫助我們幫助你。 – RealSkeptic