- 论坛徽章:
- 0
|
先贴代码- package hardwarelistenforsolaris;
- import java.io.*;
- 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();
- }
- }
- }
- }
复制代码 刚开始是创建线程失败 后面没有错误提示了 但是也没有任何结果输出 连那个txt文本也没创建 想请教下Runtime.getRuntime().exec()执行多个参数的时候到底怎么用呢 |
|