Creating a FormatterThe simplest way to get started with the Formatter class is to create a new instance of it.
Below are Formatter constructors // No-args version -- not particularly useful
public Formatter( ); // Basically, the no-args version with a locale public Formatter(Locale l); // Creates a formatter with the supplied destination (sink) public Formatter(Appendable a); // Creates a formatter with the destination, using the supplied locale public Formatter(Appendable a, Locale l); // Creates a new formatter with the filename as the sink public Formatter(String fileName); // Creates a new formatter with a file as the sink, using the specified charset public Formatter(String fileName, String csn); // Same as above, but with a locale public Formatter(String fileName, String csn, Locale l); Ccreate a Formatter targeted at a StringBuilder: StringBuilder sb = new StringBuilder( ); Formatter formatter = new Formatter(sb, Locale.FRANCE); |