[英]Executing commands with the ProcessBuilder in java
I want to run the following command from a java file command : " java hello < C:\\iptest\\input.txt > C:\\outtest\\name.txt
" hello
" will take input from " C:\\iptest\\input.txt
" and will produce an output file at " C:\\outtest\\name.txt
". codes i have done 我想从Java文件命令运行以下命令:“ java hello < C:\\iptest\\input.txt > C:\\outtest\\name.txt
” hello
“将接受来自” C:\\iptest\\input.txt
”,并在“ C:\\outtest\\name.txt
”处生成一个输出文件。
String command[]={"java","hello","< C:\\iptest\\input.txt >","C:\outtest\name.txt"};
ProcessBuilder pb=new ProcessBuilder(command);
pb.directory(new File("E:\"));
and now how to go forward i have no idea .Please Help!! 现在如何前进我不知道。请帮助!
Here is a link to the ProcessBuilder definition on Oracle, which explains how to use this class. 这是Oracle上ProcessBuilder定义的链接,该链接说明了如何使用此类。 Typically, this is used for executing non-java processes, eg .BAT or .EXE processes, but I suppose you could use it to execute any process you wish. 通常,它用于执行非Java进程,例如.BAT或.EXE进程,但是我想您可以使用它来执行所需的任何进程。
http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.