Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 30 Jan 2012 16:37:04 -0600 Date: Mon, 30 Jan 2012 14:37:03 -0800 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: how to read back the lines printed out to the console? References: <99599fa8-013c-4132-ac9e-5987d9d5588e@o13g2000vbf.googlegroups.com> In-Reply-To: <99599fa8-013c-4132-ac9e-5987d9d5588e@o13g2000vbf.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 21 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.11.53.36 X-Trace: sv3-jnnYIdGsoHxvsqPDnGDXpM0FOvYm27lnOYvQrO6K/U0GC1oGvinY6eMkDe7UFY0zYx1a7jq5HdL4Ktr!b5Dg/sg+k6YW3J0TRsp6dMo9+3SRyG4ZbkwewoEFQQf8buYi9hpBVrZ49lKtzzDegi+3fIZrFpis!XH+JOi0ajUdSn09A43V1y3571OwicMFN0E+XWX7+PsM= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2183 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11639 On 1/30/2012 12:03 PM, frame wrote: > Hi: > > We have an existing Java program, which prints out a lot of message > using System.out.println() method to the console. There are about 500 > those calls in the code. We hope to add one more feature: besides > print out to the console as it is doing now, we also want to store > those messages in a text file. So the message will be in two places: > one place -- the console -- is shown the message progressively as the > program is running; another place -- a text file -- is created at the > end of the program. ... Is it really necessary to delay creating the text file until the end? That complicates things. For example, the simplest way of using the System.setOut idea would be to write each line to both the old System.out and a text file at the same time. Similarly, the UNIX tee command writes its output file as it goes along, not just at the end. Patricia