网站首页 新闻首页 网页设计图形动画软件编程网站开发办公软件操作系统数据库网络技术认证考试范文资料黑客攻防 书籍教程 进入论坛

Java 调用批处理文件另类方法

http://www.diybl.com/ 2007-12-6  网络 点击:  [ 评论 ]
文章搜索:    【点击打包该文章】

import java.io.*;

public class Test
{
    public static void main(String[] args)
    {
        System.out.println("args : " + java.util.Arrays.asList(args));

        try
        {
            String command = args.length == 0 ? "notepad" : args[0];
            Process child = Runtime.getRuntime().exec(command);

            String line = null;
            BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
            while((line = reader.readLine()) != null)
            {
                System.out.println(line);
            }
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }

}
 

文章整理:DIY部落 http://www.diybl.com (本站)   【点击打包该文章】
如果图片或页面不能正常显示请点击这里 站内搜索:   

文章评论

请您留言