I know very well how to execute commands via Runtime.getRuntime().exec(command) and handle the output, but this is VERY limited.
Take Windows for example (Vista specifically but that shouldn't matter).
How can I execute commands like 'echo', 'cd', 'md', 'rd', and any other command rooted inside of the cmd.exe through ProcessBuilder (or whatever class) in Java?
您只需调用cmd /c dir
而不是Runtime.exec或ProcessBuilder中的dir
或以其他方式在JAVA中运行外部应用程序。
Another trick is to leverage the Ant libraries and put together a programmed version of <exec ...>
( Ant Exec Task ). This also gives you access to all kinds of Ant-supported input/output processing and filtering.
This is not writing an Ant XML script here, but calling Ant from your code .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.