ZengChang

统计

留言簿(1)

积分与排名

友情链接

阅读排行榜

评论排行榜

java如何调用DOS命令,

/*
 * Created on 2006-5-27
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.zeng;

/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

public class TestCmd {
  public static void main(String[] args) throws Exception {
   try{
    String cmd = "cmd.exe /c \"mkdir d:\\temp\\005\""; 
                      //可去掉一组引号"cmd.exe /c mkdir d:\\temp\\005"; 
                     //cmd.exe /c为固定格式,mkdir d:\\temp\\005是DOS命令,
                     //此命令在D盘创建一个目录d:\temp\005
       Runtime.getRuntime().exec(cmd); 
       }catch(Exception e){
    e.printStackTrace();
    }
   }
 }

posted on 2006-05-31 16:27 ZengChang 阅读(435) 评论(0)  编辑  收藏 所属分类: 学习笔记


只有注册用户登录后才能发表评论。


网站导航: