I am trying to build
java wrapper around a binary. The idea is that I can stream
in and out of this binary that has heavy startup time.
1) I used to be able to achieve this using ProcessBuilder ( refer to code
snippet 1 )
2) I trying to use Apache Commons Exec instead to start the binaries ( it
see from the code that it has separate threads to deal with the various streams
so that the binary dosent block due to full output or error buffers ). But, it
seems extremely complicated to open a stream/pipe to the input of the binary. I
am not sure if Code snippert 2 is the right approach to it using Piped Streams
classes.
3) One of the problems I am having is that I don't understand why the pipe
seems to close prematurely after only one write to it. Please refer to code
snippet 3 for a concise code that demonstrates the problem I am having.
Any suggestions would be appreciated.
######################## Code Snippet 1 ##############################
######################## Code Snippet 3 ##############################
######################## Code Snippet 2 ################################ import org.apache.commons.exec.*;
####################### End ##########################################