<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 6,  comments - 3,  trackbacks - 0

    調用外部應用程序(譬如VB,有應用程序窗口的情況)

    import java.io.*;
    public class execOP {

     public execOP(){
      //TODO
     }
     
     /**
      * 執行外部的程序(參數為數組).返回程序的輸出(不具有輸入的功能)
      * @param appParam   程序及參數組成的數組(每個參數為一個數組成員)
      * @return
      * @throws Exception
      */
     public String execExternalApp(String []appParam) throws Exception{
      String str="";
      
      Process proc=Runtime.getRuntime().exec(appParam);
      
      DataInputStream in = new DataInputStream(proc.getInputStream());
      DataInputStream error = new DataInputStream(proc.getErrorStream());
      
      try
      {
       String tmp="";
       while ((tmp= in.readLine()) != null) {
        str+="控制臺輸出:"+tmp+"\n";      
        //System.out.println("控制臺?出:"+tmp);  
        }
       while ((tmp= error.readLine()) != null) {     
        str+="錯誤輸出:"+tmp+"\n";             
        //System.out.println("???出:"+tmp);
       }
      }
      catch(Exception e)
      {
        System.out.println("獲取應用程序輸出時發生IO錯誤"+e.getMessage());
      }
      return str;
     }
     
     /**
      * 執行外部的程序(參數為字符串).返回程序的輸出(不具有輸入的功能)
      * @param appParam  程序及參數組成的數組(每個參數為一個數組成員)
      * @return
      * @throws Exception
      */
     public String execExternalApp(String appParam) throws Exception{
      String str="";
      
      Process proc = Runtime.getRuntime().exec(appParam);
      DataInputStream in = new DataInputStream(proc.getInputStream());
      DataInputStream error = new DataInputStream(proc.getErrorStream());
      
      try{
       String tmp="";
       while ((tmp= in.readLine()) != null) {  
        str+="空隻臺輸出:"+tmp+"\n";            
        //System.out.println("控制臺?出:"+tmp);
       }
       while ((tmp= error.readLine()) != null) {         
        str+="錯誤輸出:"+tmp+"\n";               
        //System.out.println("???出:"+tmp);  
       }
      }
      catch(Exception e){
        System.out.println("獲取應用程序輸出時發生IO錯誤:"+e.getMessage());
      }
      return str;
     }
     
     /**
      * 測試程序
      * @param args
      */
     public static void main(String[] args) {
      execOP exec=new execOP();
      
      String appcmd="\\\\IP\\c$\\Program Files\\WIPTracking\\XraySystem.exe";
      //String appcmd=args[0];
      try{
        System.out.println(exec.execExternalApp(appcmd));
      }
      catch(Exception e){
       
      }

     }

    }

    posted on 2005-10-24 13:38 Java&Inter 閱讀(764) 評論(0)  編輯  收藏 所屬分類: Java技術

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(1)

    隨筆分類(3)

    隨筆檔案(6)

    文章分類(24)

    文章檔案(22)

    收藏夾(2)

    經常去的Blog

    • Eclipse/GEF
    • 關于Eclipse插件(plugins)開發的心得,主要包括:SWT/JFACE/GEF/EMF/RCP

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲日本VA午夜在线影院| 毛片a级毛片免费播放下载| 国产成人高清精品免费观看| 久久精品国产亚洲av瑜伽| 亚洲精品伦理熟女国产一区二区| 亚洲一级毛片中文字幕| 亚洲成a人片在线看| 亚洲色精品VR一区区三区| 亚洲一级毛片免费看| 亚洲欧洲国产综合AV无码久久| 亚洲中文字幕无码av永久| 亚洲欧美日韩中文字幕一区二区三区| 亚洲日韩国产AV无码无码精品| 亚洲人成自拍网站在线观看 | 91免费国产在线观看| 香蕉97超级碰碰碰免费公| 最新免费jlzzjlzz在线播放| 在线不卡免费视频| 免费一看一级毛片| 中文亚洲AV片在线观看不卡| 亚洲成AV人片在线观看无| 久久精品国产亚洲AV无码娇色| 亚洲国产成人精品青青草原| 77777午夜亚洲| 黄色毛片免费观看| 国内永久免费crm系统z在线| 最近2019中文字幕免费直播| 国内精品乱码卡1卡2卡3免费| 日韩成人免费在线| 亚洲欧洲日产国码高潮αv| 亚洲成人午夜在线| 亚洲人成77777在线观看网| 羞羞漫画页面免费入口欢迎你| 国产免费A∨在线播放| 222www免费视频| 免费被黄网站在观看| 伊人婷婷综合缴情亚洲五月| 91久久亚洲国产成人精品性色| 亚洲综合色婷婷在线观看| 国产精品视频全国免费观看| 精品无码免费专区毛片|