Closeable
interface is a source/destination of information that can be shut. The flush() is the method Flushable interface
.
java.util Formatter Class
.
Constructors | Description |
---|---|
Formatter() | To construct new formatter. |
Formatter(File file) | To construct new formatter with particular file. |
Formatter(Locale l) | To construct new formatter with particular locale. |
Formatter(PrintStream ps) | To construct new formatter with particular print stream. |
java.util Formatter Class
.
Methods | Description |
---|---|
close() | To close the formatter. |
void flush() | To flush the formatter. |
Locale locale() | To give back the locale set by the constructor. |
Appendable out() | Destination of an output will be returned. |
String toString() | To return the result of invoking toString(). |
StringBuffer
class is to create mutable string, it can be changed.
Output: Now compile the code result will be as follows.
[java]
Welcome To SPLessons !
Exception in thread "main" java.util.FormatterClosedException
at java.util.Formatter.ensureOpen(Unknown Source)
at java.util.Formatter.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at com.SPlessons.DemoFormatter.main(DemoFormatter.java:21)
[/java]
java.util.Formatter.ioException()
is utilized to return IOException.java.util.Object class
.