OK, one possibility, a starting point anyway:
Implement a subclass of OutputStream. Have your subclass of
outputstream write contents to a buffer. Add methods to your subclass
to retrieve contents of buffer.
Now you can pass an instance of your subclass when creating an instance
of java.io.PrintStream. Pass the PrintStream instance to setErr and
setOut.
After that all things written on stdout and stderr will be going into
buffer of your subclass of OutputStream.
GIYF. Maybe someone done parts of this already.
Good luck, have fun.
PS. I'm thinking specify automatic flush when constructing PrintStream
instance with your OutputStream instance.
Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
Oliver Wong - 21 Mar 2006 17:48 GMT
<opalpa@gmail.com> wrote in message
news:1142956533.664562.248550@e56g2000cwe.googlegroups.com...
> OK, one possibility, a starting point anyway:
>
[quoted text clipped - 15 lines]
> PS. I'm thinking specify automatic flush when constructing PrintStream
> instance with your OutputStream instance.
Note that your program will not be deterministic. That is, if a message
arrives on STDOUT and another one arrives on STDERR, it is not well defined
which message arrived "first" and which one arrived "second". Be sure to
take this into account when you perform your queries on this merged buffer.
- Oliver