My code will write 8-10 strings every time a program runs but when my program is running second time it is not creating a new file instead it is appending new data in same file because of which file size is increasing. My code is as follows:
File file=new File("user. txt") ;
Printwriter pw=new PrintWriter(new BufferedWriter(new FileWriter(file. getAbsoluteFile(), true) ) ;
I know true means appending content. But when I remove true from code it is overriding my content in file and writing only last string to my file. I want to create a fresh file every time my code runs but want full data everytime my code runs not only last string.