@@ -0,0 +1,2049 @@
+package com.njust.test.kemu2;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.PrintStream;%0A%0Aimport org.junit.Test;%0A%0Apublic class ExecDemo%0A%7B%0A    /**%0A     * 1%E3%80%81%E7%A8%8B%E5%BA%8F%E8%BF%98%E6%B2%A1%E7%BB%93%E6%9D%9F%E5%B0%B1%E8%B0%83%E7%94%A8exitValue%EF%BC%8C%E4%BC%9A%E6%8A%A5%E9%94%99%E7%9A%84%0A     */%0A    @Test%0A    public void test01()%0A        throws IOException%0A    %7B%0A        Runtime runtime = Runtime.getRuntime();%0A        Process process = runtime.exec(%22notepad%22);%0A        //java.lang.IllegalThreadStateException: process has not exited%0A        int exitValue = process.exitValue();%0A        System.out.println(exitValue);%0A    %7D%0A    %0A    @Test%0A    public void test02()%0A        throws IOException, InterruptedException%0A    %7B%0A        Runtime runtime = Runtime.getRuntime();%0A        Process process = runtime.exec(%22notepad%22);%0A        //%E4%BC%9A%E9%98%BB%E5%A1%9E%E4%B8%BB%E7%BA%BF%E7%A8%8B%EF%BC%8C%E5%9C%A8%E5%85%B3%E9%97%AD%E5%86%99%E5%AD%97%E6%9C%AC%E4%B9%8B%E5%90%8E%E6%89%8D%E4%BC%9A%E6%89%93%E5%8D%B0finish%0A        //%E6%9C%AA%E8%AF%BB%E5%8F%96%E7%BC%93%E5%86%B2%E5%8C%BA%EF%BC%8C%E7%BC%93%E5%86%B2%E5%8C%BA%E5%8F%AF%E8%83%BD%E8%80%97%E5%B0%BD%0A        process.waitFor();%0A        %0A        System.out.println(%22finish%22);%0A    %7D%0A    %0A    @Test%0A    public void test03()%0A        throws IOException, InterruptedException%0A    %7B%0A        Runtime runtime = Runtime.getRuntime();%0A        Process process = runtime.exec(%22notepad%22);%0A        %0A        //%E6%AD%A3%E7%A1%AE%E7%9A%84%E6%96%B9%E6%B3%95%E5%A4%84%E7%90%86%E6%AD%A3%E5%B8%B8%E8%BE%93%E5%87%BA%E5%92%8C%E9%94%99%E8%AF%AF%E8%BE%93%E5%87%BA%0A        StreamGobbler outputStream = new StreamGobbler(process.getInputStream(), System.out);%0A        StreamGobbler errorStream = new StreamGobbler(process.getErrorStream(), System.err);%0A        outputStream.start();%0A        errorStream.start();%0A        %0A        int exitValue = process.waitFor();%0A        System.out.println(%22exitValue:%22 + exitValue);%0A        %0A        outputStream.join();%0A        errorStream.join();%0A        %0A        System.out.println(%22finish%22);%0A    %7D%0A%7D%0A%0Aclass StreamGobbler extends Thread%0A%7B%0A    InputStream is;%0A    %0A    PrintStream os;%0A    %0A    StreamGobbler(InputStream is, PrintStream os)%0A    %7B%0A        this.is = is;%0A        this.os = os;%0A    %7D%0A    %0A    public void run()%0A    %7B%0A        try%0A        %7B%0A            int c;%0A            while ((c = is.read()) != -1)%0A            %7B%0A                os.print((char)c);%0A            %7D%0A        %7D%0A        catch (IOException x)%0A        %7B%0A            // handle error%0A        %7D%0A    %7D%0A%7D%0A

Create ExecDemo.java