static void goOut(String in) {
//instance variables
String fileCopy = currentLine + in;
try {
FileWriter writer = new FileWriter(output,true);
writer.write(line1 + System.getProperty("line.separator", "\r\n"));
writer.write(fileCopy + System.getProperty("line.separator", "\r\n"));
} catch(IOException ex) {
ex.printStackTrace();
}
}
將編碼修改爲正確的標準,正如其他用戶指出的那樣。Java多次寫入寫入行?
爲什麼要創建兩個寫入同一文件的'FileWriter'對象?這聽起來像是一場災難。 –
感謝您的回覆。我試圖解決這個問題,但它沒有奏效。使用一個FileWriter它也不起作用。 – Adz
你可以再次打電話給作家嗎? 'write.write(fileCopy + System.get ....)',然後調用'writer.close();' –