67,513
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
String cmd = geneCmd();
Process pro;
try {
System.out.println("begin process");
pro = Runtime.getRuntime().exec(cmd);
int waitTime = pro.waitFor();
System.out.println(waitTime);
System.out.println("end process");
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
static String geneCmd(){
String str = "ls -l\n";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1000; i++) {
sb.append(str);
}
return sb.toString();
}