0
我想寫下面寫入文件和
private static void writeToFile(String string, String fileFromList) throws IOException {
// TODO Auto-generated method stub
StringBuilder images=new StringBuilder();
images=images.append(string).append(fileFromList);
System.out.println("inside database");
File resultFile = new File("input/phocagallery.tsv");
BufferedWriter resultWriter = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(resultFile),
"UTF-8"));
resultWriter.write(images.toString());
resultWriter.close();
}
我打電話從另一個循環這個功能使用的代碼一些數據文件,每次追加..但我的問題是,我只有一個項目寫入文件..當一個新的File對象創建每次當函數調用它會創建一個新文件並插入?爲什麼我將所有的值插入到數據庫中?
的可能重複[寫入文件,而不刪除舊數據](http://stackoverflow.com/questions/13938886/write-file-without-deleting-older-data),http://stackoverflow.com/questions/ 6027764 /如何追加數據到文件和http://stackoverflow.com/questions/369760/java-append-to-file。 – hmjd