Hi all,
I have this problem:
I have an errorstream to parse, I got the stderr in this way
BufferedReader err =
new BufferedReader
(new InputStreamReader(p.getErrorStream()));
I have to pass the buffer err to two methods, but after passing the
buffer to the first method it is empty.
In this method to read the buffer I use err.readline().
Any suggestions on how to copy the buffer or other way for solving the
problem
thx in advance
derek - 17 Jan 2008 18:19 GMT
> BufferedReader err =
> new BufferedReader
> (new InputStreamReader(p.getErrorStream()));
> I have to pass the buffer err to two methods, but after passing the
> buffer to the first method it is empty.
> In this method to read the buffer I use err.readline().
Well once you read from a stream the data is no longer in the stream.
I am guessing in my response since you didnt post any code with your question.
If you posted some code it would help.
You will need to save the data you read from the stream if you intend to continue to use it.
After you save it then you could pass it to the other two methods.
.
=====================================================
THIS IS MY SIGNATURE. There are many like it, but this one is mine.
Andrea - 17 Jan 2008 18:46 GMT
> > BufferedReader err =
> > new BufferedReader
[quoted text clipped - 12 lines]
> =====================================================
> THIS IS MY SIGNATURE. There are many like it, but this one is mine.
Actually my question is how to save a stream?
Mike Schilling - 17 Jan 2008 19:56 GMT
>> > BufferedReader err =
>> > new BufferedReader
[quoted text clipped - 10 lines]
>> continue to use it.
>> After you save it then you could pass it to the other two methods.
> Actually my question is how to save a stream?
Read all of the data into a byte array. You can construct as many
ByteArrayInputStreams from the result as you like.
Roedy Green - 17 Jan 2008 18:22 GMT
>Any suggestions on how to copy the buffer or other way for solving the
>problem
See http://mindprod.com/applet/fileio.html
for how to direct a stream to a String.
Normally though you compose Strings with a StringBuilder, not a
stream.
Consider using your own logging method it he app, then you can decide
what to do with the messages in a central place.

Signature
Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com