0

JSP からバッチ ファイルを実行する必要がありますが、コードはバッチ ファイル実行ステートメントの後に次の行に移動し、バッチ ファイルの実行が完了するまで待機しません。試してみwaitfor()ましたが、無限ループに陥ります。

だから今、私は別の解決策を選択しました.JSPによって実行される私のバッチファイルは、システム上のファイルを変更します.だから、whileループを入れて、ファイルの変更時刻と現在のシステム時刻をチェックしました. この場合もwhileループは永遠に続きます。

いずれかのアプローチで助けてください。

      Process p = Runtime.getRuntime().exec("C:\\TOMCAT\\apache-tomcat-6.0.37\\webapps\\ROOT\\vcc_support_automation\\jsp\\List_user_utility.bat");
      SimpleDateFormat sdfDate = new SimpleDateFormat("MM/dd/yyyy HH:mm");
      Date now = new Date();
      String strDate = sdfDate.format(now);
      File file = new File("C:\\TOMCAT\\apache-tomcat-6.0.37\\webapps\\ROOT\\vcc_support_automation\\jsp\\duplicate_users_list.txt");
      SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
      String mdfDate = sdf.format(file.lastModified());
      strDate.replaceAll("\\s","");
      mdfDate.replaceAll("\\s","");
       while (true){
       if(strDate.equals(mdfDate))
       {
           System.out.println("hello");
           break;
            }
       }  
4

0 に答える 0