开发者

Java shell expansion similar to wordexp

Is there a way to do shell wildca开发者_JAVA技巧rd 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!


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


If you want more extensive pattern support, take a look at java.nio.file.Files, 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 ~.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜