📄 procmethod.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 + -