Formatter flush() method in Java with Examples
The flush() method is a built-in method of the java.util.Formatter which flushes the formatter. Writing any buffered output in its destination to the underlying operating system is referred to as Flushing.
public void flush()
Parameters: The function accepts no parameter.
Return Value: The function returns nothing, it just flushes the formatter. Hence the return type is void.
Errors and Exceptions: The function throws a FormatterClosedException when this function is used after closing the formatter.
Below is the implementation of the above function:
What is your name? My name is Gopal Dave ! Flushed
What is your name? My name is Gopal Dave ! Exception is: java.util.FormatterClosedException
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.