🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: aus.computers.java
2 messages
2 total messages Started by jam Thu, 20 May 1999 00:00
println, print?!
#1135
Author: jam
Date: Thu, 20 May 1999 00:00
26 lines
1339 bytes
Hi, something is really strange with my java program, can anyone pls
help?

At some point of my program, there are the below 2 lines...

     String received = new String(inPL.Msg,0,30);
     System.out.print(received);

Note: inPL.Msg is of type byte[] from a class.
The strange thing is, when I have that in a loop, it doesn't get printed
out if I have it as print, but if i have it as println, it is fine (but
of course I don't want to have a line feed every time!)

In case u need some background of my whole program:
A program with 2 threads, one thread receiving message from a socket,
and the other thread sends out.  The above lines are from my receiving
thread.

Anyone had anything like that happened to them before? if so, how did u
solve it?
Is there anything in java that is kind of like fflush() in C that flush
the stdin/out put??

Thanks heaps

Regards, James.
Re: println, print?!
#1136
Author: James Cribb
Date: Thu, 20 May 1999 00:00
19 lines
1078 bytes
In article <37441330.98141F7D@ihug.com.au>, jam wrote:
| 
|      System.out.print(received);
| 
| The strange thing is, when I have that in a loop, it doesn't get printed
| out if I have it as print, but if i have it as println, it is fine

Sounds like System.out is line-buffered.  You'd expect it to be.

| Is there anything in java that is kind of like fflush() in C that flush
| the stdin/out put??

System.out is a java.io.PrintStream, which has a public void flush() method.
In other words, use

  System.out.flush().

Do you have the manuals for Java?  If not, they're on-line at
http://www.javasoft.com/products/jdk/1.2/docs/index.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads