簡單記錄:

private static final String FILENAME = "E:\\test\\filename.txt";

File file = new File(FILENAME);

// if file doesnt exists, then create it
if (!file.exists()) {
  file.createNewFile();
}

// true = append file
FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(data);

bw.close();
fw.close();

來源:Java – How to append content to file

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()