Runtime.getRuntime().exec()执行多命令问题,求解答
先上代码package hardwarelistenforsolaris;
import *;
import java.util.Scanner;
public class HardwareListenForSolaris {
public static void main(String[] args) throws FileNotFoundException, IOException {
// TODO code application logic here
PrintStream ps = null;
FileInputStream fis = null;
try
{
ps = new PrintStream(new FileOutputStream("test.txt"));
String[] cmd = {"cmd.exe ","/c","ipconfig","netstat"," > F:\\ababab.txt"};
// Process p= Runtime.getRuntime().exec("cmd.exe /c ipconfig > F:\\more.txt");
Process p= Runtime.getRuntime().exec(cmd);
}
catch(IOException ex)
{
ex.printStackTrace();
}
finally
{
if(ps != null)
{
ps.close();
}
}
}
}
我想要的结果是在一个进程里面启动cmd 然后输入ipconfig 和netstat之类的命令 并把输出打印到一个txt里面 现在出了不知道什么错误的错误 求解答 谢谢