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(); } } }
标签:java,process,clear,命令,BufferedReader,ubuntu,line From: https://www.cnblogs.com/herd/p/17527008.html