java 调用CMD命令 demo

try {
            Runtime run = Runtime.getRuntime();
            String[] cmd = new String[] {
                    "cmd.exe","/C","mysqldump -uroot -p111111  test> c:/test.sql"};
            Process p = run.exec(cmd);
            p.waitFor();
            System.out.println("end.");
        } catch (Exception e) {
            e.printStackTrace();
        }