create a new and unique file each time the function is compiled. that means if file exists already before execution of the program then it should delete the file and create a new file and append the new data. or add the content after just deleting the complete data which is already there in the same file.
I have created something like this....
Writer output = new BufferedWriter(new FileWriter("C:\\" + bankAccNo + ".txt", true));
output.append(myRow.getCell(0).toString()+ "\n");
output.close();