main.java
来自「java的经典例子」· Java 代码 · 共 25 行
JAVA
25 行
import java.io.*;
class Main {
public static void main(String[] args) {
try {
String cmd = "ls";
Process child = Runtime.getRuntime().exec(cmd);
// Wait for child to finish
int status;
try {
status = child.waitFor();
} catch (InterruptedException e) {
status = -1;
}
// Display exit status of subprocess
if (status == 0)
System.out.println("process successfully completed.");
else
System.out.println("process exited with " + status);
} catch (IOException e) {
System.err.println(e);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?