indraniria
3 years agoContributor
How to use "break in the following loop?
for(File file: f.listFiles())
{
if (file.getName().contains(date_time) ||file.getName().contains(next_day)){
file.eachLine{line ->
if(line.contains(text)){
log.info file.getName()
break
}
}
}
Getting below error:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 23: the break statement is only allowed inside loops or switches
@ line 23, column 5.
break
^
}