zhijin 发表于 2013-1-27 04:50:43

java 调用bat文件

 
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifimport java.io.*;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifimport java.util.*;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gifpublic class TestExec ...{   
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif    public void runbat(int timeFortmat) ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif        String cmd = "cmd /c start D:/ScheduleRun/data/"+timeFortmat+".bat";
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif        try ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif            Process ps = Runtime.getRuntime().exec(cmd);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif            System.out.println(ps.getInputStream());
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif        } catch(IOException ioe) ...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif            ioe.printStackTrace();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif        }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif    }          
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif    
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif    public static void main(String[] args)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif           TestExec  test1 = new TestExec ();           
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif           test1.runbat(1340);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif    }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}     
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
页: [1]
查看完整版本: java 调用bat文件