src/java.base/share/classes/java/util/Formatter.java

Print this page




1818  *
1819  * <blockquote><pre>
1820  *   formatter.format("%s %s %s %s", "a", "b", "c", "d")
1821  *   // -&gt; "a b c d"
1822  * </pre></blockquote>
1823  *
1824  * </ul>
1825  *
1826  * <p> It is possible to have a format string which uses all forms of indexing,
1827  * for example:
1828  *
1829  * <blockquote><pre>
1830  *   formatter.format("%2$s %s %&lt;s %s", "a", "b", "c", "d")
1831  *   // -&gt; "b a a b"
1832  *   // "c" and "d" are ignored because they are not referenced
1833  * </pre></blockquote>
1834  *
1835  * <p> The maximum number of arguments is limited by the maximum dimension of a
1836  * Java array as defined by
1837  * <cite>The Java&trade; Virtual Machine Specification</cite>.
1838  * If the argument index is does not correspond to an
1839  * available argument, then a {@link MissingFormatArgumentException} is thrown.
1840  *
1841  * <p> If there are more arguments than format specifiers, the extra arguments
1842  * are ignored.
1843  *
1844  * <p> Unless otherwise specified, passing a {@code null} argument to any
1845  * method or constructor in this class will cause a {@link
1846  * NullPointerException} to be thrown.
1847  *
1848  * @author  Iris Clark
1849  * @since 1.5
1850  */
1851 public final class Formatter implements Closeable, Flushable {
1852     private Appendable a;
1853     private final Locale l;
1854 
1855     private IOException lastException;
1856 
1857     private final char zero;
1858     private static double scaleUp;




1818  *
1819  * <blockquote><pre>
1820  *   formatter.format("%s %s %s %s", "a", "b", "c", "d")
1821  *   // -&gt; "a b c d"
1822  * </pre></blockquote>
1823  *
1824  * </ul>
1825  *
1826  * <p> It is possible to have a format string which uses all forms of indexing,
1827  * for example:
1828  *
1829  * <blockquote><pre>
1830  *   formatter.format("%2$s %s %&lt;s %s", "a", "b", "c", "d")
1831  *   // -&gt; "b a a b"
1832  *   // "c" and "d" are ignored because they are not referenced
1833  * </pre></blockquote>
1834  *
1835  * <p> The maximum number of arguments is limited by the maximum dimension of a
1836  * Java array as defined by
1837  * <cite>The Java&trade; Virtual Machine Specification</cite>.
1838  * If the argument index does not correspond to an
1839  * available argument, then a {@link MissingFormatArgumentException} is thrown.
1840  *
1841  * <p> If there are more arguments than format specifiers, the extra arguments
1842  * are ignored.
1843  *
1844  * <p> Unless otherwise specified, passing a {@code null} argument to any
1845  * method or constructor in this class will cause a {@link
1846  * NullPointerException} to be thrown.
1847  *
1848  * @author  Iris Clark
1849  * @since 1.5
1850  */
1851 public final class Formatter implements Closeable, Flushable {
1852     private Appendable a;
1853     private final Locale l;
1854 
1855     private IOException lastException;
1856 
1857     private final char zero;
1858     private static double scaleUp;