How do I iterate over all lines of files passed on the commandline in Groovy?
- by Shuja
Hi
I want to read whole file contents in groovy on command line.
I am using this code
#!/usr/bin/env groovy
def xmlData =""
System.in.withReader {
xmlData=xmlData+ it.readLine()
}
println xmlData
and the following command
cat 1.xml | /root/a.groovy
But it only reads one line from the file. I want to read whole file.
Any suggestion??
Regards
Shuja