Script for replace the data into the file content using groovy with jsr223
import java.nio.file.* def usdcor = vars.get('TestData_name') //TestData_name was defined in userdefined or any corralted value log.info("Current Working Directory: " + System.getProperty("user.dir")) // Path to the file to be updated def filePath = "./Scripts/file.txt" // Replace with your file's path // Define the new content def newData = "This is the new content being added./\n asdfasdfasdfasdfsadf" + usdcor try { // Overwrite the file with the new content (clears the old data) Files.write(Paths.get(filePath), newData.getBytes()) log.info("File content replaced successfully!") } catch (Exception e) { log.error("Error while updating the file: " + e.getMessage()) }