[英]How to add a new line in a file without overwriting current line?
我目前有。
public void openFile(){
try{
x = new Formatter("Data.text");
}
catch(Exception e){
System.out.println("File not created");
}
}
。 。 。 。
。
。
public void addRecords(){
x.format("%s %s %s %s", first(), last(), ID(), num());
}
但是在我運行文件之后,它每次都會覆蓋數據嗎?
格式化程序會將文件的大小截斷為0。改用PrintWriter 。 然后,您可以使用PrintWriter的printf執行相同的操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.