Chapter    11

Formatter

The description of JSR 51 (http://jcp.org/en/jsr/detail?id=51) indicates that a simple printf-style formatting facility was proposed for inclusion in NIO. If you’re familiar with the C language, you’ve probably worked with the printf() family of functions that support formatted output.

One feature that makes the printf() functions useful is varargs, which lets you pass a variable number of arguments to these functions. Because support for varargs wasn’t added to Java until JDK 5, and because this support is very useful for achieving formatted output, the printf-style formatting facility was deferred to JDK 5.

This chapter explores JDK 5’s printf-style formatting facility.

Exploring Formatter

JDK 5 introduced the java.util.Formatter ...

Get Java I/O, NIO and NIO.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.