views:

118

answers:

1

Hello,

I would like to implement something equivalent to the unix command 'rm foo*' using Java. Obviously, I want it to be multi platform. I know that this can be done using the FilenameFilter class and File.delete() method, but I was wondering if I can perform this simple operation in a less verbose way.

Thanks in advance.

+1  A: 

Look in commons-io for org.apache.commons.io.filefilter.WildcardFileFilter.

And no, sorry, even though it is verbose, it doesn't get much less verbose than that. Groovy and Scala are good choices if you want to write concise scripts.

Nathan Hughes