Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: method parameter binding Date: Thu, 10 Dec 2015 18:00:25 -0000 (UTC) Organization: A noiseless patient Spider Lines: 37 Message-ID: References: <6bfa4a78-934e-4f90-8e5f-a2f56e529842@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 10 Dec 2015 18:00:25 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="27065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NxF26gmnNPG1lQZePsXRgmM6uQ/QRbz0=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:Ru1JuCGCeo/kGRKjwagc0lyvr7A= Xref: csiph.com comp.lang.java.programmer:33341 On Thu, 10 Dec 2015 11:35:48 -0500, Eric Sosman wrote: > Could it be that System.out and System.err are two different > and independent PrintStreams, each with its own buffering and making its > own decisions about when to flush buffers? > > Naaah, too simple ... > That's certainly the case in the UNIX/Linux world, where stdout, which System.out maps to, is quite extensively buffered while stderr, which System.err uses, is unbuffered. Normally it all works as expected if you only use stdout or stderr, but use both, e.g. for debugging, and the actual output from mixed stdout and stderr print statements does not necessarily appear in the same order as the statements were executed. As Jan says, this can be confusing, especially if you're capturing the output in a single stream using something like: myprog 2>&1 |less because you know the output is much bigger than one screen's worth and you want to search it or page through it using the 'less' utility. Similarly, in C you can output a prompt with fprintf(stderr, "....") and follow it immediately with a read to get user input, but if you used print ("....") or fprintf(stdout, "....") you need to call fflush(stdout) to make sure the prompt has been displayed before attempting to read the user input. I don't recall whether Windows does the same. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |