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 / April 2007

Tip: Looking for answers? Try searching our database.

How to combine a process's ErrorStream and InputStream to one buffer?

Thread view: 
ruthie - 16 Apr 2007 11:13 GMT
Hello friends,

I am trying to write a process's prints into a log.

Using the Process API I can do this:

m_compileProcess = Runtime.getRuntime().exec(commandline);
BufferedReader err = new BufferedReader(
                   new
InputStreamReader(m_compileProcess.getErrorStream()));
BufferedReader out = new BufferedReader(
                   new
InputStreamReader(m_compileProcess.getInputStream()));

But what I really need is to get the error stream and the output
stream to go into the same place.
How do I go about that??

thanks,
ruthie
Gordon Beaton - 16 Apr 2007 12:09 GMT
> But what I really need is to get the error stream and the output
> stream to go into the same place. How do I go about that??

There are two alternatives:
- use ProcessBuilder instead of Runtime.exec
- use shell redirection in the command itself

/gordon

--
ruthie - 16 Apr 2007 12:40 GMT
>  - use ProcessBuilder instead of Runtime.exec

It works, thanks!
This is exactly what I needed.
ruthie


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.