Java Doc for Formatter.java in  » Apache-Harmony-Java-SE » java-package » java » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.Formatter

Formatter
final public class Formatter implements Closeable,Flushable(Code)
Formatter provides the method to give out formatted string just like the printf-style. Layout,alignment and other format flags are provided to format numeric,string and date/time as well as locale-specified formats applied. Besides primitive types, formatter also support some java object types such as BigInteger,BigDecimal and Calendar. Customized formatting is provided through the Formattable interface. The class is not multi-threaded safe. The responsibility to maintain thread safety is the user's job.
since:
   1.5

Inner Class :public enum BigDecimalLayoutForm


Constructor Summary
public  Formatter()
     Constructs a formatter.
public  Formatter(Appendable a)
     Constructs a formatter of which the output is denoted. The locale for the formatter is the default locale of the JVM.
Parameters:
  a - The output of the formatter.
public  Formatter(Locale l)
     Constructs a formatter of which the locale is denoted. The output destination is a StringBuilder which can be achieved by invoking the out method and whose contents can be attained by calling the toString method.
Parameters:
  l - The locale of the formatter.
public  Formatter(Appendable a, Locale l)
     Constructs a formatter of which the output and locale is denoted.
Parameters:
  a - The output of the formatter.
public  Formatter(String fileName)
     Constructs a formatter of which the filename is denoted. The charset of the formatter is the default charset of JVM. The locale for the formatter is the default locale of the JVM.
Parameters:
  fileName - The filename of the file that is used as the outputdestination for the formatter.
public  Formatter(String fileName, String csn)
     Constructs a formatter of which the filename and charset is denoted. The locale for the formatter is the default locale of the JVM.
Parameters:
  fileName - The filename of the file that is used as the outputdestination for the formatter.
public  Formatter(String fileName, String csn, Locale l)
     Constructs a formatter of which the filename, charset and locale is denoted.
Parameters:
  fileName - The filename of the file that is used as the outputdestination for the formatter.
public  Formatter(File file)
     Constructs a formatter of which the file is denoted. The charset of the formatter is the default charset of JVM. The locale for the formatter is the default locale of the JVM.
Parameters:
  file - The file that is used as the output destination for theformatter.
public  Formatter(File file, String csn)
     Constructs a formatter of which the file and charset is denoted. The locale for the formatter is the default locale of the JVM.
Parameters:
  file - The file of the file that is used as the output destinationfor the formatter.
public  Formatter(File file, String csn, Locale l)
     Constructs a formatter of which the file, charset and locale is denoted.
Parameters:
  file - file that is used as the output destination for the formatter.The file will be truncated to zero size if the file exists, orelse a new file will be created.
public  Formatter(OutputStream os)
     Constructs a formatter of which the output destination is specified.
public  Formatter(OutputStream os, String csn)
     Constructs a formatter of which the output destination and the charset is specified.
public  Formatter(OutputStream os, String csn, Locale l)
     Constructs a formatter of which the output destination, the charset and the locale is specified.
Parameters:
  os - The stream used as the destination of the formatter.
Parameters:
  csn - The name of the charset for the formatter.
Parameters:
  l - The locale of the formatter.
public  Formatter(PrintStream ps)
     Constructs a formatter of which the output destination is specified. The charset of the formatter is the default charset of JVM. The locale for the formatter is the default locale of the JVM.
Parameters:
  ps - The print stream used as destination of the formatter.

Method Summary
public  voidclose()
     Closes the formatter.
public  voidflush()
     Flushes the formatter.
public  Formatterformat(String format, Object... args)
     Writes a formatted string to the output destination of the formatter.
Parameters:
  format - A format string.
Parameters:
  args - The arguments list used in the format() method.
public  Formatterformat(Locale l, String format, Object... args)
     Writes a formatted string to the output destination of the formatter.
Parameters:
  l - The locale used in the method.
public  IOExceptionioException()
     Returns the last IOException thrown out by the formatter's output destination.
public  Localelocale()
     Returns the locale of the formatter.
public  Appendableout()
     Returns the output destination of the formatter.
public  StringtoString()
     Returns the content by calling the toString() method of the output destination.


Constructor Detail
Formatter
public Formatter()(Code)
Constructs a formatter. The output is a StringBuilder which can be achieved by invoking the out method and whose contents can be attained by calling the toString method. The locale for the formatter is the default locale of the JVM.



Formatter
public Formatter(Appendable a)(Code)
Constructs a formatter of which the output is denoted. The locale for the formatter is the default locale of the JVM.
Parameters:
  a - The output of the formatter. If a is null, then aStringBuilder will be used.



Formatter
public Formatter(Locale l)(Code)
Constructs a formatter of which the locale is denoted. The output destination is a StringBuilder which can be achieved by invoking the out method and whose contents can be attained by calling the toString method.
Parameters:
  l - The locale of the formatter. If l is null, then nolocalization will be used.



Formatter
public Formatter(Appendable a, Locale l)(Code)
Constructs a formatter of which the output and locale is denoted.
Parameters:
  a - The output of the formatter. If a is null, then aStringBuilder will be used.
Parameters:
  l - The locale of the formatter. If l is null, then nolocalization will be used.



Formatter
public Formatter(String fileName) throws FileNotFoundException(Code)
Constructs a formatter of which the filename is denoted. The charset of the formatter is the default charset of JVM. The locale for the formatter is the default locale of the JVM.
Parameters:
  fileName - The filename of the file that is used as the outputdestination for the formatter. The file will be truncated tozero size if the file exists, or else a new file will becreated. The output of the formatter is buffered.
throws:
  FileNotFoundException - If the filename does not denote a normal and writable file,or a new file cannot be created or any error rises whenopening or creating the file.
throws:
  SecurityException - If there is a security manager and it denies writing to thefile in checkWrite(file.getPath()).



Formatter
public Formatter(String fileName, String csn) throws FileNotFoundException, UnsupportedEncodingException(Code)
Constructs a formatter of which the filename and charset is denoted. The locale for the formatter is the default locale of the JVM.
Parameters:
  fileName - The filename of the file that is used as the outputdestination for the formatter. The file will be truncated tozero size if the file exists, or else a new file will becreated. The output of the formatter is buffered.
Parameters:
  csn - The name of the charset for the formatter.
throws:
  FileNotFoundException - If the filename does not denote a normal and writable file,or a new file cannot be created or any error rises whenopening or creating the file.
throws:
  SecurityException - If there is a security manager and it denies writing to thefile in checkWrite(file.getPath()).
throws:
  UnsupportedEncodingException - If the charset with the specified name is not supported.



Formatter
public Formatter(String fileName, String csn, Locale l) throws FileNotFoundException, UnsupportedEncodingException(Code)
Constructs a formatter of which the filename, charset and locale is denoted.
Parameters:
  fileName - The filename of the file that is used as the outputdestination for the formatter. The file will be truncated tozero size if the file exists, or else a new file will becreated. The output of the formatter is buffered.
Parameters:
  csn - The name of the charset for the formatter.
Parameters:
  l - The locale of the formatter. If l is null, then nolocalization will be used.
throws:
  FileNotFoundException - If the filename does not denote a normal and writable file,or a new file cannot be created or any error rises whenopening or creating the file.
throws:
  SecurityException - If there is a security manager and it denies writing to thefile in checkWrite(file.getPath()).
throws:
  UnsupportedEncodingException - If the charset with the specified name is not supported.



Formatter
public Formatter(File file) throws FileNotFoundException(Code)
Constructs a formatter of which the file is denoted. The charset of the formatter is the default charset of JVM. The locale for the formatter is the default locale of the JVM.
Parameters:
  file - The file that is used as the output destination for theformatter. The file will be truncated to zero size if the fileexists, or else a new file will be created. The output of theformatter is buffered.
throws:
  FileNotFoundException - If the file does not denote a normal and writable file, or anew file cannot be created or any error rises when opening orcreating the file.
throws:
  SecurityException - If there is a security manager and it denies writing to thefile in checkWrite(file.getPath()).



Formatter
public Formatter(File file, String csn) throws FileNotFoundException, UnsupportedEncodingException(Code)
Constructs a formatter of which the file and charset is denoted. The locale for the formatter is the default locale of the JVM.
Parameters:
  file - The file of the file that is used as the output destinationfor the formatter. The file will be truncated to zero size ifthe file exists, or else a new file will be created. Theoutput of the formatter is buffered.
Parameters:
  csn - The name of the charset for the formatter.
throws:
  FileNotFoundException - If the file does not denote a normal and writable file, or anew file cannot be created or any error rises when opening orcreating the file.
throws:
  SecurityException - If there is a security manager and it denies writing to thefile in checkWrite(file.getPath()).
throws:
  UnsupportedEncodingException - If the charset with the specified name is not supported.



Formatter
public Formatter(File file, String csn, Locale l) throws FileNotFoundException, UnsupportedEncodingException(Code)
Constructs a formatter of which the file, charset and locale is denoted.
Parameters:
  file - file that is used as the output destination for the formatter.The file will be truncated to zero size if the file exists, orelse a new file will be created. The output of the formatteris buffered.
Parameters:
  csn - The name of the charset for the formatter.
Parameters:
  l - The locale of the formatter. If l is null, then nolocalization will be used.
throws:
  FileNotFoundException - If the file does not denote a normal and writable file, or anew file cannot be created or any error rises when opening orcreating the file.
throws:
  SecurityException - If there is a security manager and it denies writing to thefile in checkWrite(file.getPath()).
throws:
  UnsupportedEncodingException - If the charset with the specified name is not supported.



Formatter
public Formatter(OutputStream os)(Code)
Constructs a formatter of which the output destination is specified. The charset of the formatter is the default charset of JVM. The locale for the formatter is the default locale of the JVM.
Parameters:
  os - The stream used as the destination of the formatter.



Formatter
public Formatter(OutputStream os, String csn) throws UnsupportedEncodingException(Code)
Constructs a formatter of which the output destination and the charset is specified. The locale for the formatter is the default locale of the JVM.
Parameters:
  os - The stream used as the destination of the formatter.
Parameters:
  csn - The name of the charset for the formatter.
throws:
  UnsupportedEncodingException - If the charset with the specified name is not supported.



Formatter
public Formatter(OutputStream os, String csn, Locale l) throws UnsupportedEncodingException(Code)
Constructs a formatter of which the output destination, the charset and the locale is specified.
Parameters:
  os - The stream used as the destination of the formatter.
Parameters:
  csn - The name of the charset for the formatter.
Parameters:
  l - The locale of the formatter. If l is null, then nolocalization will be used.
throws:
  UnsupportedEncodingException - If the charset with the specified name is not supported.



Formatter
public Formatter(PrintStream ps)(Code)
Constructs a formatter of which the output destination is specified. The charset of the formatter is the default charset of JVM. The locale for the formatter is the default locale of the JVM.
Parameters:
  ps - The print stream used as destination of the formatter. If psis null, then NullPointerExcepiton will be thrown out.




Method Detail
close
public void close()(Code)
Closes the formatter. If the output destination is Closeable , then the method close() will be called on that destination. If the formatter has been closed, then calling the close will have no effect. Any method but the ioException() that is called after the formatter has been closed will raise a FormatterClosedException.



flush
public void flush()(Code)
Flushes the formatter. If the output destination is Flushable , then the method flush() will be called on that destination.
throws:
  FormatterClosedException - If the formatter has been closed.



format
public Formatter format(String format, Object... args)(Code)
Writes a formatted string to the output destination of the formatter.
Parameters:
  format - A format string.
Parameters:
  args - The arguments list used in the format() method. If there aremore arguments than those specified by the format string, thenthe additional arguments are ignored. This formatter.
throws:
  IllegalFormatException - If the format string is illegal or incompatible with thearguments or the arguments are less than those required bythe format string or any other illegal situation.
throws:
  FormatterClosedException - If the formatter has been closed.



format
public Formatter format(Locale l, String format, Object... args)(Code)
Writes a formatted string to the output destination of the formatter.
Parameters:
  l - The locale used in the method. If locale is null, then nolocalization will be applied. This parameter does notinfluence the locale specified during construction.
Parameters:
  format - A format string.
Parameters:
  args - The arguments list used in the format() method. If there aremore arguments than those specified by the format string, thenthe additional arguments are ignored. This formatter.
throws:
  IllegalFormatException - If the format string is illegal or incompatible with thearguments or the arguments are less than those required bythe format string or any other illegal situation.
throws:
  FormatterClosedException - If the formatter has been closed.



ioException
public IOException ioException()(Code)
Returns the last IOException thrown out by the formatter's output destination. If the append() method of the destination will not throw IOException, the ioException() method will always return null. The last IOException thrown out by the formatter's outputdestination.



locale
public Locale locale()(Code)
Returns the locale of the formatter. The locale for the formatter and null for no locale.
throws:
  FormatterClosedException - If the formatter has been closed.



out
public Appendable out()(Code)
Returns the output destination of the formatter. The output destination of the formatter.
throws:
  FormatterClosedException - If the formatter has been closed.



toString
public String toString()(Code)
Returns the content by calling the toString() method of the output destination. The content by calling the toString() method of the outputdestination.
throws:
  FormatterClosedException - If the formatter has been closed.



Methods inherited from java.lang.Object
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final public Class<? extends Object> getClass()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
final public void notify()(Code)(Java Doc)
final public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final public void wait(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait(long millis) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.