⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 procmethod.java

📁 pso源程序
💻 JAVA
字号:
/**
 * Description: miscellenaous operations, esp. for run alien process.
 *
 * @ Author        Create/Modi     Note
 * Xiaofeng Xie    Oct 13, 2001    xiaofengxie@tsinghua.org.cn
 *
 * @version 1.0
 */

package Global.system;

 public class ProcMethod {

  static public boolean ISPROCESSEXIT = false;

  static public Process createAlienProcess(String simulationStr) throws Exception {
    String realString = simulationStr;
    String osRelativedCommand = OSRelativedMethods.getProcessHandlerName();
    if(osRelativedCommand!=""&&!simulationStr.startsWith(osRelativedCommand)) {
      realString = osRelativedCommand+" "+realString;
    }
    return Runtime.getRuntime().exec(realString);
  }


  static public int runAlienProcess(Process proc) throws Exception {
    ProcStreamReader stdoutReader =
        new ProcStreamReader(proc.getInputStream());
    ProcStreamReader stderrReader =
        new ProcStreamReader(proc.getErrorStream());
    stdoutReader.start();
    stderrReader.start();
    int returnValue = proc.waitFor();
    System.out.println(stdoutReader.getData());
    System.err.println(stderrReader.getData());
    stdoutReader.stop();
    stderrReader.stop();

    return(returnValue);
  }

/* Run an external program specified by give simulationStr
 **/
  static public int runAlienProcess(String simulationStr) throws Exception {
    Process simuProcess = createAlienProcess(simulationStr);
    return(runAlienProcess(simuProcess));
  }

  /**
   * Create an RunObject instance with an ObjectType.
   */
    public static Object createObject(String key) throws Exception{
      Class cls = Class.forName(key);
      return cls.newInstance();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -