java运行ubuntu clear命令
import java.io.BufferedReader; import java.io.InputStreamReader; public class ClearScreen { public static void main(String[] args) { try { // 执行clear命令 Process process = Runtime.getRuntime().exec("clear"); // 读取命令输出 BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream())); String line; while ((line = reader.readLine()) != null) { System.out.println(line); } // 等待命令执行完成 process.waitFor(); } catch (Exception e) { e.printStackTrace(); } } }
QQ 3087438119