1

I have a condition in Jmeter that the extracted data from the file have to be deleted one by one. Actual situation is, I am getting some IDs from json and saving it in txt file. During my test, I have to delete the Json Content by ID and then I have to clear the text file. Since I am using fragment as test case, while the Thread count increases, the delete statement takes the first line from the txt file and so the same ID getting deleted again and again.

I am using below script to delete the file, but there is no change in the file

try {
            File file = new File("groupId.txt");
            PrintWriter writer = new PrintWriter(file);
            writer.print("");
            writer.close();
            line=$(head -n 1 file)
        } catch (Exception e) {

     }

Either I have to configure to increase the line index or I have to clear the ID from the txt file after using it.

Deepak Sabastein
  • 197
  • 3
  • 16

1 Answers1

0

In order to update file you need to save it in a temporary file and then remove old file and rename temp file.see solution

Ori Marko
  • 56,308
  • 23
  • 131
  • 233