複製程式碼如下: BufferedWriter 輸出 = null;嘗試 { out = new BufferedWriter(new FileWriter(“檔案名稱”, true)); out.write("aString"); } catch (IOException e) { // 錯誤處理程式碼} 最後 {如果(輸出!=空){關閉(); } }