Reputation: 475
def file= new File(path + 'fileName.csv');
List.unique().each { element ->
file<< element << newLine
}
Upvotes: 0
Views: 1633
Reputation: 168207
The easiest is to delete the file prior to writing to it via i.e. Files.deleteIfExists() function Add the next line to your script which will remove the file if it's present already:
java.nio.file.Files.deleteIfExists(file.toPath())
Full code just in case:
def file = new File(path + 'fileName.csv');
java.nio.file.Files.deleteIfExists(new File().toPath())
List.unique().each { element ->
file << element << newLine
}
See The Groovy Templates Cheat Sheet for JMeter for more hints
Upvotes: 1