Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

Copying ErrorStream

Thread view: 
Andrea - 17 Jan 2008 16:51 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.