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



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
.



Relevant Pages

  • Re: System.out PrintWriter print() and flush() not flushing?
    ... While the program is listening and not receiving a message I simply ... Does anyone know how to print only a dot without a newline? ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (comp.lang.java.help)
  • Re: System.out PrintWriter print() and flush() not flushing?
    ... I have a thread that listens to a server socket. ... While the program is listening and not receiving a message I simply ... Does anyone know how to print only a dot without a newline? ... if (wasNullBefore) ...
    (comp.lang.java.help)
  • Re: System.out PrintWriter print() and flush() not flushing?
    ... While the program is listening and not receiving a message I simply ... PrintStream rather than PrintWriter. ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (comp.lang.java.help)
  • Re: Death in a Scotch Sitting Room - another one gone
    ... Any chance of another series of ISIHAC soon? ... Get a digital radio, listen to an old ISIHAC every Monday. ... Which means not listening to R4 at 6:30pm as well as at the usual ... groups at asylum dot nildram dot co dot uk ...
    (uk.misc)
  • Re: Spectrum WAV/MP3s ?
    ... listening to a screen$ loading sound not totally unpleasant? ... I used to like listening to speccy loading sounds. ... Annoy his mind here: pjf at cmp dot liv dot ack dot ook ...
    (comp.sys.sinclair)