首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java调用shell,并失去shell的输出

2012-10-28 
java调用shell,并得到shell的输出import java.io.IOExceptionimport java.io.InputStreamReaderimport j

java调用shell,并得到shell的输出

import java.io.IOException;import java.io.InputStreamReader;import java.io.LineNumberReader;public class RunShell {public static void main(String[] args) {try {///opt/flow_video/flow_total.sh 2011-05-26 11:08:02 12:08:07 192.168.1.152,192.168.1.153Process process = Runtime.getRuntime().exec("/opt/flow_video/tf.sh 2011-05-23 11:08:02 12:08:07");InputStreamReader ir = new InputStreamReader(process.getInputStream());LineNumberReader input = new LineNumberReader(ir);String line;while ((line = input.readLine()) != null)System.out.println(line);input.close();ir.close();} catch (IOException e) {e.printStackTrace();}}}

热点排行