java Runtime.getRunTime().exec 和通配符?

2024-05-24

我正在尝试使用删除垃圾文件

Process p = Runtime.getRuntime().exec();

只要我不使用通配符,它​​就可以正常工作,即:

Process p = Runtime.getRuntime().exec("/bin/rm -f specificJunkFile.java");

而以下返回“没有这样的文件或目录”:

Process p = Runtime.getRuntime().exec("/bin/rm -f *.java");

我应该能够做所概述的所有好事here http://www.tuxfiles.org/linuxhelp/wildcards.html, right?


经过大量搜索后我发现了这个:http://www.coderanch.com/t/423573/java/java/Passing-wilcard-Runtime-exec-command http://www.coderanch.com/t/423573/java/java/Passing-wilcard-Runtime-exec-command

Runtime.exec(new String[] { "sh", "-c", "rm /tmp/ABC*" });
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

java Runtime.getRunTime().exec 和通配符? 的相关文章

随机推荐