Copying ErrorStream

A

Andrea

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
 
D

derek

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.
 
R

Roedy Green

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.
 
A

Andrea

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.

Actually my question is how to save a stream?
 
M

Mike Schilling

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top