There is a writeToFile method that writes the necessary data to a .txt file, the problem is that the text is overwritten each time, but I need to be added.
public void writeToFile(def directory, def fileName, def extension, def infoList) { new File("$directory/$fileName$extension").withWriter { out -> infoList.each { out.println it } and here is the code on which I test the method
def directory = 'C:/Task_1' def c def txtFileInfo = [] txtFileInfo << "Ваши данные - ${U_id}" txtFileInfo << "И ваши данные... - ${B_num}" writeToFile(directory, "info", ".txt", txtFileInfo