Java Reference
In-Depth Information
name to use. An additional constructor takes a PrintStream as a destina-
tion, but only the default platform encoding is used.
Formatter supports localization (see Chapter 24 ) and for each type of
destination there is an additional constructor that takes a Locale object
with which the formatter should work. If you do not specify a locale to
the constructor, the default locale is used. The locale being used is re-
turned by the locale method.
The destination of a Formatter object can be obtained from the out meth-
od, which returns an Appendable object.
If writing to the destination object could throw an IOException , then the
last IOException to occur (if any) can be obtained from the ioException
method.
Formatter implements Closeable and Flushable . If close or flush are in-
voked, then the destination is also closed or flushed if it too implements
Closeable or Flushable . Once a formatter has been closed the only meth-
od that can be invoked is ioException ; all others throw FormatterClosedEx-
ception .
The primary method of Formatter is, of course, format :
public Formatter format(String format, Object... args)
Formats the given arguments according to the given format
string and writes them through to the destination object. The
current Formatter object is returned, allowing format invoca-
tions to be chained together.
public Formatter format(Locale loc, String format, Object... args)
Like the above format method, but uses the specified locale
instead of the one from the current Formatter .
The Formatter class's support of localized output is restricted to a subset
of the numeric conversions (and the date/time conversions discussed in
 
Search WWH ::




Custom Search