LucN
6 years agoOccasional Contributor
How to get the next 15 line after the date with groovy script
Hello eveyrone, I have another problem,
I'm trying to get a number of line after a specific date is found in my file. for example, if I found the date in my File, I would like to write, in ano...
- 6 years ago
I'll anwser myslef since I solved it :
writeFile.withWriter { writer -> // read the file using a reader readFile.withReader{ reader -> while (line = reader.readLine()) { // if line starts with your comment "'" if(line.contains(threadInfo)){ def lineCount = 0 while(lineCount < lineCountMax) { def nextLine = reader.readLine() // to the current line, and writeit in the result file writer << "${nextLine}" << System.properties.'line.separator' lineCount ++; } } } } }
thx anyaway !