Yes, especially when buffers are used you should flush pending output before the program ends.
Yet another advantage of
PrintWriter is that
you can ask it to automatically flush its data everytime a
println() is executed.
(But it is still a good precaution to
the stream when you are through with it.)
Here is a list of some of the constructors and methods
For a complete list of methods refer to your
None of the methods throw exceptions.
PrintWriter(Writer out) Create a new PrintWriter and connect it to the Writer out. Automatic line flushing is not enabled. PrintWriter(Writer out, boolean autoFlush) Create a new PrintWriter and connect it to the Writer out. Automatic line flushing is enabled if autoFlus is true.
public boolean checkError() Flush the stream. If there has been an error in output the method returns true. public void close() throws IOException Flush the stream and close the file. public void flush() throws IOException Flush the stream. public void print(char c) Print the character c. public void print(double d) Translate into characters and print the double value d. public void print(float f) Translate into characters and print the float value f. public void print(int i) Translate into characters and print the int value i. public void print(String s) Print the String s. public void print( various other data types) See your complete documentation. public void println() Terminate the current output line and (possibly) flush the stream. public void println( various data types) See your complete documentation.