• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Apache Commons Exec Piping to Input Stream using PipedInputStream

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ##########################################
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this topic to the Groovy forum...

Henry
 
reply
    Bookmark Topic Watch Topic
  • New Topic