Re: System.out PrintWriter print() and flush() not flushing?



On 29 Feb., 05:54, Knute Johnson <nos...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Karsten Wutzke wrote:
Hello!

I have a thread that listens to a server socket. When a message
arrives, I print it via

System.out.println("...");

While the program is listening and not receiving a message I simply
want to print one dot "." so the user can see the program is still
listening. However, the dots are not printed, they only appear after
another call to println(). I also call flush() after print but it
doesn't flush the buffer.

Does anyone know how to print only a dot without a newline? How?

Karsten

Are you trying to read from the console too? If that is the case I
think you will be unsuccessful.

From the docs for PrintWriter

"Unlike the PrintStream class, if automatic flushing is enabled it will
be done only when one of the println, printf, or format methods is
invoked, rather than whenever a newline character happens to be output.
These methods use the platform's own notion of line separator rather
than the newline character."

This could be part of the problem too. Maybe it would be better to use
PrintStream rather than PrintWriter.

--

Knute Johnson
email s/nospam/knute/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Oops... I meant PrintStream from the beginning of my posting. So the
subject should read:

"System.out PrintStream print() and flush() not flushing?"

How do I go? Using

System.out.print(".");
System.out.flush();

Does not show the dot immediately as I'd like...

Karsten
.



Relevant Pages

  • Re: Thetford flush additives - newbie
    ... If you look above the cassette toilet outside door there will be a filler ... cap with a lock on it similar to a car petrol cap, try opening that, you ... The model is a Thetford C200 which appears to just take the flush feed ... e-mail messages to bill hyphen lord at uku dot co dot uk ...
    (uk.rec.caravanning)
  • Re: Thetford flush additives - newbie
    ... bog ... The model is a Thetford C200 which appears to just take the flush feed from ... The roof poles have a hook on the end which fits into the pads, ... e-mail messages to bill hyphen lord at uku dot co dot uk ...
    (uk.rec.caravanning)
  • Re: ABS brakes?
    ... On older bikes, flush out the DOT 3 or 4 and install ... > DOT 5 silicone brake fluid. ...
    (rec.motorcycles.tech)
  • Re: Bob Dylan on CD quality
    ... one spoke ill of you while you were not here? ... I thought of him with every flush, ... George, how many times have they warned you about trying to flush your ...
    (rec.audio.opinion)