It's not a secret anymore!*
The moose likes Groovy and the fly likes Apache Commons Exec Piping to Input Stream using PipedInputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Apache Commons Exec Piping to Input Stream using PipedInputStream" Watch "Apache Commons Exec Piping to Input Stream using PipedInputStream" New topic
Author

Apache Commons Exec Piping to Input Stream using PipedInputStream

arun sharan
Greenhorn

Joined: Jun 06, 2006
Posts: 4
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 ##########################################
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18510
    
  40

Moving this topic to the Groovy forum...

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Apache Commons Exec Piping to Input Stream using PipedInputStream
 
Similar Threads
OutputStream -> InputStream
getting console output into a JTextArea
Piped Streams ( pipedinputstream and pipedoutputstream )
Why don't write array of characters in a BufferedOutputStream using Piped?
RTP and Java 3D sounds