public class GroovyWordSort {
File dataFile
List words = []
public GroovyWordSort(fileName){
dataFile = new File(fileName)
}
def sortedWords(){
if (!words){
dataFile.eachLine{it.tokenize().each {words.add(it) }}
words = words.sort{w,w1 -> w.toLowerCase() <=> w1.toLowerCase()}
}
words
}
}
Wednesday, May 20, 2009
JavaOne Talk: Groovy Word Sort
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment