views:

52

answers:

2

Is there a way to do shell wildcard expansion in java similar to the way that the C function call wordexp works? It seems a bit platform specific, but there has to be a nice abstraction for this in one of the java system classes, right? I would be happy if I could get ~/, ./, and ../ to resolve to their canonical paths. Thanks!

+1  A: 

If you just want to replace . and .., you may use File.getCanonicalPath()

Dmitry
A: 

If you want more extensive pattern support, take a look at java.nio.Path, in particular methods such as newDirectoryStream. Search through the page for the word "glob". There is more information in the Sun File Operations tutorial page. (This flavour of 'globbing' supports *, **, ?, [...] and {...}, but not ~.)

Stephen C