Class BufferedPipe



  • public class BufferedPipe
    extends Object
    This pipes data from an InputStream to a PrintStream.

    The original intended usage for this class is:

    Process process = ...;
     new BufferedPipe(process.getInputStream(), System.out);
     new BufferedPipe(process.getErrorStream(), System.err);

    On construction this immediately creates a new thread that buffers the InputStream until no more data is available.

    (I'm surprised/confused the PipedInputStream and PipedOutputStream are so narrowly defined that they don't already support this functionality?)

    • Method Detail

      • process

        protected void process(String s)
        Process a buffered line of text as it is becomes available. Subclasses can override this to provide additional functionality. The default implementation here simply relays this text to the PrintStream provided on construction.
        Parameters:
        s - the new line of text to process.