java

推荐列表 站点导航

当前位置:首页 > 脚本编程 > java >

复制代码 代码如下: public class StreamGobbler extends Thread { Inpu

来源:网络  作者:网友投稿  发布时间:2021-01-16 03:44
java执行Linux呼吁的要领,本文实例报告了java执行Linux呼吁的要领。分享给各人供各人参考。详细实现要领如下:复制代...

, String type) { this.is = is; this.type = type; } public void run() { try { InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { if (type.equals("Error")) { System.out.println("Error :" + line); } else { System.out.println("Debug:" + line); } } } catch (IOException ioe) { ioe.printStackTrace(); } } } private void shell(String cmd) { String[] cmds = { "/bin/sh",然后再读取尺度输出流 2.最好的执行系统呼吁的要领就是写个bat文件或是shell剧本, "Output"); errorGobbler.start(); outputGobbler.start(); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } } 个中参数 cmd 为Linux呼吁, "Error"); StreamGobbler outputGobbler = new StreamGobbler(process.getInputStream(),每次只能执行一条呼吁, 复制代码 代码如下: public class StreamGobbler extends Thread { InputStream is; String type; public StreamGobbler(InputStream is, 1.Java Runtime.exec()留意事项: ① 永远要在挪用waitFor()要领之前读取数据流 ② 永远要先从尺度错误流中读取。

"-c", cmd }; Process process; try { process = Runtime.getRuntime().exec(cmds); StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(),。

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/java/12692.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

复制代码 代码如下: public class StreamGobbler extends Thread { Inpu

2021-01-16 编辑:网友投稿

, String type) { this.is = is; this.type = type; } public void run() { try { InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { if (type.equals("Error")) { System.out.println("Error :" + line); } else { System.out.println("Debug:" + line); } } } catch (IOException ioe) { ioe.printStackTrace(); } } } private void shell(String cmd) { String[] cmds = { "/bin/sh",然后再读取尺度输出流 2.最好的执行系统呼吁的要领就是写个bat文件或是shell剧本, "Output"); errorGobbler.start(); outputGobbler.start(); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } } 个中参数 cmd 为Linux呼吁, "Error"); StreamGobbler outputGobbler = new StreamGobbler(process.getInputStream(),每次只能执行一条呼吁, 复制代码 代码如下: public class StreamGobbler extends Thread { InputStream is; String type; public StreamGobbler(InputStream is, 1.Java Runtime.exec()留意事项: ① 永远要在挪用waitFor()要领之前读取数据流 ② 永远要先从尺度错误流中读取。

"-c", cmd }; Process process; try { process = Runtime.getRuntime().exec(cmds); StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(),。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/java/12692.shtml

相关文章

风云图片

推荐阅读

返回java频道首页