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 閱讀(457) 評論(0) 編輯 收藏 所屬分類: 學習筆記