java中运行系统命令

            ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "dir", "c:");
            Process p = pb.start();
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream(), "gbk"));
            String line;

和其他系统命令不一样,“dir” is built-in to the windows shell (cmd.exe) and can't be run as a simple executable
“ipconfig /all”命令就可以直接运行


你可能感兴趣的:(java中运行系统命令)