本文介绍了Windows上的Java运行时exec重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Windows上执行此命令,但似乎Java exec无法使用重定向.我该如何解决这个问题?
I want to execute this command on windows, but It seems Java exec is not working with the redirect. How can I solve this problem?
c:/coolroid/gicater/mysqldump.exe -h127.0.0.1 -uroot -pagile -P3308 coolroid > C:/jukebackup/coolroid_1498793488965.bak
推荐答案
String [] command = {"cmd" , "/C" ,cmd + " >" + finalPath};
Process p = Runtime.getRuntime().exec(command);
问题已解决.cmd:c:/coolroid/gicater/mysqldump.exe -h127.0.0.1 -uroot -pagile -P3308 coolroidfinalPath:C:/jukebackup/coolroid_1498793488965.bak
The problem is solved.cmd : c:/coolroid/gicater/mysqldump.exe -h127.0.0.1 -uroot -pagile -P3308 coolroid finalPath: C:/jukebackup/coolroid_1498793488965.bak
感谢您的提示@ControlAltDel感谢@Don Peat纠正了我的问题.
Thanks for your tips @ControlAltDelThanks @Don Peat for correcting my question.
这篇关于Windows上的Java运行时exec重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!