I have a file with integers for which I want the average. Below is what I came up with and it works, but was wondering if there was a better (groovier) way..
File myFile = new File("myListOfNumbers.txt")
int total = 0
int count = 0
myFile.eachLine {line->
total = Integer.parseInt(line) + total
count++
}
println "Avg is ${total /count}"