shell process java synchronization -


i want run shell script java program. shell script invokes system library needs big file resource.

my java program calls script every word in document. if call script again , again using runtime.exec() time taken high since resource loading takes lot of time.

to overcome thought of writing shell script follows (to make run continuously in background ):


count=0  while count -lt 10 ;    read word    //execute command on line  done 

i need retrieve output of command in java program , process further. how should code i/o operations achieving task?

i have tried writing words in process's output stream , reading output process's input stream. not work , throws broken pipe exception.


try {      parseresult = runtime.getruntime().exec(parsecommand);      parsingresultsreader = new bufferedreader(new inputstreamreader (parseresult.getinputstream()));      errorreader = new bufferedreader(new inputstreamreader (parseresult.geterrorstream()));      parseresultswriter = new bufferedwriter(new outputstreamwriter((parseresult.getoutputstream())));  } catch (ioexception e) {              e.printstacktrace();  } 

parseresultswriter.write(word);  parseresultswriter.flush();  while ((line = parsingresultsreader.readline()) != null) {       // capture output in list here  } 

kindly issue

//execute command on line 

is command separate program? launched every word, you'll rid of shell process lightweight anyway. have learn how run heavyweight command many words @ once.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -