Do simulation if feeder file exists


I’m simulation a two part scenario where the first part creates the feeder file for the second part but while compiling, Gatling sees that the file doesn’t exist and so it can’t locate it.

Caused by: java.lang.IllegalArgumentException: Could not locate feeder file: file EditFilteringResult1.json doesn’t exist

I tried surrounding the code with a doIf (the file exists)

exec(session =>{

session.set(“fileExists”, new"…/user-files/data/" + filteringFileName + (x + 1).toString() + “.json”).exists)
feed(jsonFile( filteringFileName + (x + 1).toString() + “.json”))

Any ideas?