« Return to Thread: I have a gut feeling there is a better way to do this....

I have a gut feeling there is a better way to do this....

by phil swenson :: Rate this Message:

Reply to Author | View in Thread

I need a function that returns if a directory has any files in it (directories don't count).  Here's my take:

def noFilesInDirectory(dir){
def file = new File(dir)
def i = 0
file.eachFileRecurse(){
    if (it.isFile()){
        i++
    }
}
return i == 0
}

I think there is a better way... what is it?

 « Return to Thread: I have a gut feeling there is a better way to do this....

LightInTheBox - Buy quality products at wholesale price!