nitzanp (1) [Avatar] Offline
i am trying to learn how to work with the groovy language, and my problem is:
I want to read every line from a file and then to print only specific lines.(those who include a specific string)
how can I do it? thanks!
Mittie (397) [Avatar] Offline
Re: reading a file and printing it with a filter

this kind of question should better go to the Groovy mailing list, but since it is so easy to anser:

new File('myfile.txt').eachLine { if (it.contains('groovy')) println it }

for more variants of achieving the same effect have a look into the GDK chapter of the first edition.

keep groovin'