filewriter is appending rather than overwriting code example
Example: filewriter java overwrite
import java.io.*;
FileWriter fwriter = new Filewriter("filename.txt" , true) //true for append, false for overwrite
import java.io.*;
FileWriter fwriter = new Filewriter("filename.txt" , true) //true for append, false for overwrite