- package cn.text;
- import java.io.*;
- import java.util.Scanner;
-
- public class Foo {
-
- 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里面 |
|