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

JAVA调用shell命令时重定向、管道时遇到的有关问题

2012-10-18 
JAVA调用shell命令时重定向、管道时遇到的问题用java在Linux环境下执行shell命令,可以使用如下方法:import

JAVA调用shell命令时重定向、管道时遇到的问题
用java在Linux环境下执行shell命令,可以使用如下方法:

import java.io.IOException;public class JavaShell{        /**         * @param args         * @throws IOException         * @throws InterruptedException         */        public static void main(String[] args) throws IOException, InterruptedException        {                Process p;                p = Runtime.getRuntime().exec(new String[]{"sh","-c","md5sum a.c > a.c.md5"});                if(0==p.waitFor())                {                        System.out.println("Command execute result is OK!");                }                else                {                        System.out.println("Command execute result is fail......");                }        }}


Reference:
http://hi.baidu.com/litertiger/blog/item/822a7ef049c913d47831aa19.html
http://blog.csdn.net/georgejin/archive/2010/10/13/5937877.aspx
http://hi.baidu.com/zhangtianshun/blog/item/ae632246b572b40e6a63e579.html

转自:http://www.liaoqiqi.com/blog/2011/java-call-shell-command-redirection-pipeline-problems/

热点排行