- Java.util - WeakHashMap
- Java.util - Vector
- Java.util - UUID
- Java.util - TreeSet
- Java.util - TreeMap
- Java.util - TimeZone
- Java.util - TimerTask
- Java.util - Timer
- Java.util - StringTokenizer
- Java.util - Stack
- Java.util - SimpleTimeZone
- Java.util - ServiceLoader
- Java.util - Scanner
- Java.util - ResourceBundle.Control
- Java.util - ResourceBundle
- Java.util - Random
- Java.util - PropertyResourceBundle
- Java.util - PropertyPermission
- Java.util - Properties
- Java.util - PriorityQueue
- Java.util - Observable
- Java.util - Locale
- Java.util - ListResourceBundle
- Java.util - LinkedList
- Java.util - LinkedHashSet
- Java.util - LinkedHashMap
- Java.util - IdentityHashMap
- Java.util - Hashtable
- Java.util - HashSet
- Java.util - HashMap
- Java.util - GregorianCalendar
- Java.util - Formatter
- Java.util - EnumSet
- Java.util - EnumMap
- Java.util - Dictionary
- Java.util - Date
- Java.util - Currency
- Java.util - Collections
- Java.util - Calendar
- Java.util - BitSet
- Java.util - Arrays
- Java.util - ArrayList
- Java.util - ArrayDeque
- Java.util - Home
Java.util Package Extras
- Java.util - Discussion
- Java.util - Useful Resources
- Java.util - Enumerations
- Java.util - Exceptions
- Java.util - Interfaces
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.util.Formatter Class
Introduction
The java.util.Formatter class provides support for layout justification and apgnment, common formats for numeric, string, and date/time data, and locale-specific output.Following are the important points about Formatter −
Formatters are not necessarily safe for multithreaded access.Thread safety is optional and is the responsibipty of users of methods in this class.
Class declaration
Following is the declaration for java.util.Formatter class −
pubpc final class Formatter extends Object implements Closeable, Flushable
Class constructors
Sr.No. | Constructor & Description |
---|---|
1 | Formatter() This constructor constructs a new formatter. |
2 | Formatter(Appendable a) This constructor constructs a new formatter with the specified destination. |
3 | Formatter(Appendable a, Locale l) This constructor constructs a new formatter with the specified destination and locale. |
4 | Formatter(File file) This constructor constructs a new formatter with the specified file. |
5 | Formatter(File file, String csn) This constructor constructs a new formatter with the specified file and charset. |
6 | Formatter(File file, String csn, Locale l) This constructor constructs a new formatter with the specified file, charset, and locale. |
7 | Formatter(Locale l) This constructor constructs a new formatter with the specified locale. |
8 | Formatter(OutputStream os) This constructor constructs a new formatter with the specified output stream. |
9 | Formatter(OutputStream os, String csn) This constructor constructs a new formatter with the specified output stream and charset. |
10 | Formatter(OutputStream os, String csn, Locale l) This constructor constructs a new formatter with the specified output stream, charset, and locale. |
11 | Formatter(PrintStream ps) This constructor constructs a new formatter with the specified print stream. |
12 | Formatter(String fileName) This constructor constructs a new formatter with the specified file name. |
13 | Formatter(String fileName, String csn) This constructor constructs a new formatter with the specified file name and charset. |
14 | Formatter(String fileName, String csn, Locale l) This constructor constructs a new formatter with the specified file name, charset, and locale. |
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method closes this formatter. |
2 | This method flushes this formatter. |
3 | This method writes a formatted string to this object s destination using the specified locale, format string, and arguments. |
4 | This method writes a formatted string to this object s destination using the specified format string and arguments. |
5 | This method returns the IOException last thrown by this formatter s Appendable. |
6 | This method returns the locale set by the construction of this formatter. |
7 | This method returns the destination for the output. |
8 | This method returns the result of invoking toString() on the destination for the output. |
Methods inherited
This class inherits methods from the following classes −
java.util.Object