main.java
来自「java的经典例子」· Java 代码 · 共 26 行
JAVA
26 行
import java.io.*;
class Main {
public static void main(String[] args) {
// some code that captures output from 'ls'
try {
String cmd = "ls";
Process child = Runtime.getRuntime().exec(cmd);
// Wait for child to finish
try {
child.waitFor();
} catch (InterruptedException e) {
}
// Display exit status of subprocess
int status = child.exitValue();
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 + -
显示快捷键?