Im creating a java app in which some text is to be stored in a text file. But store function will run in a loop where every cycle will fetch data from other classes and store in the text file. I want that my text file should store data on each cycle just like you create log. here is some piece of code:
public void store(){
File file = new File("PaperRecord.txt");
try{
PrintWriter fout = new PrintWriter(file);
fout.println("Paper Name: " + super.getpSame());
fout.println("Paper Size: " + super.getpSize());
fout.println("Paper Year: " + super.getpYear());
fout.println("Paper Author: " + super.getpAuthor());
fout.println("Paper Description: " + getpDesc());
fout.println("Paper Signature: " + getpSign());
fout.println("Email: " + getPEmail());
fout.println("");
}
catch(FileNotFoundException e){
//do nothing
}
}
Calling store function from main using loop:
while(!q.isEmpty()){
Papers temp = q.remove();
temp.print();
temp.store();
}
THe problem currently with this code is that the code create new file paperrecord each time or overrite existing. I want the same file to be increased and updated downward (more text added)