java - Running batch file as a thread not a process -


am trapped in situation need ... infinitely , create process i.e batch file converts given file.pdf file.txt problem facing ,,, in order on files , program creating process run batch file , waits finish , create process ... , on , consuming resources how can save resources ?

string[] arg = { "cmd", "/c", "bat.exe", "-layout", arg0,             arg1};     try {           processbuilder builder = new processbuilder(arg);         builder.redirecterrorstream(true);         process p2 = builder.start();         bufferedreader reader = new bufferedreader(new inputstreamreader(                 p2.getinputstream()));         string line;         while ((line = reader.readline()) != null) {             system.out.println(line);         }         p2.waitfor();      } catch (ioexception e) {         e.printstacktrace();     } catch (interruptedexception e) {         // todo auto-generated catch block         e.printstacktrace();     } 

where arg0 , arg1 pdf file , destination text file respectively

apache commons exec free. have @ section unblock execution in tutorial.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -