Runtime runtime = Runtime.getRuntime();
      Process process = null;
      String command = "xxxxxx";
      process = runtime.exec(command);
如何知道这个命令是否运行成功?

解决方案 »

  1.   

    Runtime runtime = Runtime.getRuntime();
          Process process = null;
          String command = "xxxxxx";
          try {
    process = runtime.exec(command);
    process.exitValue();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }int java.lang.Process.exitValue()Returns the exit value for the subprocess. 
    Returns:
    the exit value of the subprocess represented by this Process object. by convention, the 
     value 0 indicates normal termination.
    Throws:
    IllegalThreadStateException if the subprocess represented by this Process object has not 
     yet terminated.
      

  2.   

    int exitValue =process.exitValue();