🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
2 messages
2 total messages Started by Zhilei Ma Tue, 26 Nov 2002 16:55
a question about PrintWirter.
#730
Author: Zhilei Ma
Date: Tue, 26 Nov 2002 16:55
30 lines
1694 bytes
Hello all,

i habe wrote a code piece like the following:

import java.io.*;

public class PrintWriterDemo
{
    public static void main(String[] args) throws IOException
    {
 PrintWriter pw = new PrintWriter(System.out, false);
 pw.println("this is a String.");

 int i=-7;
 pw.println(i);

 double d = 2.4e-7;
 pw.println(d);
    }
}

when i run this programm, it output nothing, until i changed the parameter
of the constructor of PrintWriter from "false" to "true". I know that the
boolean paremeter means that "autoFlush - A boolean; if true, the println()
methods will flush the output buffer". But i cann't good understand it. Can
anyone explain it to me?

Thanks a lot!

Zhilei
Re: a question about PrintWirter.
#734
Author: John
Date: Thu, 28 Nov 2002 16:02
41 lines
2158 bytes
The PrintWriter is buffered.  It will only flush itself when println()
is called and autoFlush is turned on (true).  There is a method called
flush() in which you can do the flushing yourself.

John


On Tue, 26 Nov 2002 17:55:49 +0100, "Zhilei Ma" <zhilei.ma@iao.fhg.de>
wrote:

>Hello all,
>
>i habe wrote a code piece like the following:
>
>import java.io.*;
>
>public class PrintWriterDemo
>{
>    public static void main(String[] args) throws IOException
>    {
> PrintWriter pw = new PrintWriter(System.out, false);
> pw.println("this is a String.");
>
> int i=-7;
> pw.println(i);
>
> double d = 2.4e-7;
> pw.println(d);
>    }
>}
>
>when i run this programm, it output nothing, until i changed the parameter
>of the constructor of PrintWriter from "false" to "true". I know that the
>boolean paremeter means that "autoFlush - A boolean; if true, the println()
>methods will flush the output buffer". But i cann't good understand it. Can
>anyone explain it to me?
>
>Thanks a lot!
>
>Zhilei
>
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