Java Doc for PrintWriter.java in  » Apache-Harmony-Java-SE » java-package » java » io » 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.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.Writer
      java.io.PrintWriter

PrintWriter
public class PrintWriter extends Writer (Code)
PrintWriter is a class which takes either an OutputStream or Writer and provides convenience methods for printing common data types in a human readable format on the stream. No IOExceptions are thrown by this class. Instead, callers should call checkError() to see if a problem has been encountered in this Writer.


Field Summary
protected  Writerout
     The writer to output data to.

Constructor Summary
public  PrintWriter(OutputStream out)
     Constructs a new PrintWriter on the OutputStream out.
public  PrintWriter(OutputStream out, boolean autoflush)
     Constructs a new PrintWriter on the OutputStream out.
public  PrintWriter(Writer wr)
     Constructs a new PrintWriter on the Writer wr.
public  PrintWriter(Writer wr, boolean autoflush)
     Constructs a new PrintWriter on the given writer.
public  PrintWriter(File file)
     Constructs a new PrintWriter on the File file.
public  PrintWriter(File file, String csn)
     Constructs a new PrintWriter on the File file.
public  PrintWriter(String fileName)
     Constructs a new PrintWriter on a file with the given file name fileName.
public  PrintWriter(String fileName, String csn)
     Constructs a new PrintWriter on a file with the given file name fileName.

Method Summary
public  PrintWriterappend(char c)
     Append a char cto the PrintWriter.
public  PrintWriterappend(CharSequence csq)
     Append a CharSequence csq to the PrintWriter.
public  PrintWriterappend(CharSequence csq, int start, int end)
     Append a subsequence of a CharSequence csq to the PrintWriter.
public  booleancheckError()
     Answers a boolean indicating whether or not this PrintWriter has encountered an error.
public  voidclose()
     Close this PrintWriter.
public  voidflush()
     Flush this PrintWriter to ensure all pending data is sent out to the target Writer.
public  PrintWriterformat(String format, Object... args)
     Writes a string formatted by an intermediate Formatter to this writer using the given format string and arguments.
public  PrintWriterformat(Locale l, String format, Object... args)
     Writes a string formatted by an intermediate Formatter to this writer using the given format string and arguments.
public  voidprint(char[] charArray)
     Prints the String representation of the character array parameter charArray to the target Writer.
public  voidprint(char ch)
     Prints the String representation of the character parameter ch to the target Writer.
public  voidprint(double dnum)
     Prints the String representation of the double parameter dnum to the target Writer.
public  voidprint(float fnum)
     Prints the String representation of the float parameter fnum to the target Writer.
public  voidprint(int inum)
     Prints the String representation of the int parameter inum to the target Writer.
public  voidprint(long lnum)
     Prints the String representation of the long parameter lnum to the target Writer.
public  voidprint(Object obj)
     Prints the String representation of the Object parameter obj to the target Writer.
public  voidprint(String str)
     Prints the String representation of the String parameter str to the target Writer.
public  voidprint(boolean bool)
     Prints the String representation of the boolean parameter bool to the target Writer.
public  PrintWriterprintf(String format, Object... args)
     Prints a formatted string.
public  PrintWriterprintf(Locale l, String format, Object... args)
     Prints a formatted string.
public  voidprintln()
     Prints the String representation of the System property "line.separator" to the target Writer.
public  voidprintln(char[] charArray)
     Prints the String representation of the character array parameter charArray to the target Writer followed by the System property "line.separator".
public  voidprintln(char ch)
     Prints the String representation of the character parameter ch to the target Writer followed by the System property "line.separator".
public  voidprintln(double dnum)
     Prints the String representation of the double parameter dnum to the target Writer followed by the System property "line.separator".
public  voidprintln(float fnum)
     Prints the String representation of the float parameter fnum to the target Writer followed by the System property "line.separator".
public  voidprintln(int inum)
     Prints the String representation of the int parameter inum to the target Writer followed by the System property "line.separator".
public  voidprintln(long lnum)
     Prints the String representation of the long parameter lnum to the target Writer followed by the System property "line.separator".
public  voidprintln(Object obj)
     Prints the String representation of the Object parameter obj to the target Writer followed by the System property "line.separator".
public  voidprintln(String str)
     Prints the String representation of the String parameter str to the target Writer followed by the System property "line.separator".
public  voidprintln(boolean bool)
     Prints the String representation of the boolean parameter bool to the target Writer followed by the System property "line.separator".
protected  voidsetError()
     Set the flag indicating that this PrintWriter has encountered an IO error.
public  voidwrite(char buf)
     Writes the entire character buffer buf to this Writer.
public  voidwrite(char buf, int offset, int count)
     Writes count characters starting at offset in buf to this Writer.
public  voidwrite(int oneChar)
     Writes the specified character to this Writer.
public  voidwrite(String str)
     Writes the characters from the String str to this Writer.
public  voidwrite(String str, int offset, int count)
     Writes count characters from the String str starting at offset to this Writer.

Field Detail
out
protected Writer out(Code)
The writer to output data to.




Constructor Detail
PrintWriter
public PrintWriter(OutputStream out)(Code)
Constructs a new PrintWriter on the OutputStream out. All writes to the target can now take place through this PrintWriter. By default, the PrintWriter is set to not autoflush when println() is called.
Parameters:
  out - the the OutputStream to provide convenience methods on.



PrintWriter
public PrintWriter(OutputStream out, boolean autoflush)(Code)
Constructs a new PrintWriter on the OutputStream out. All writes to the target can now take place through this PrintWriter. By default, the PrintWriter is set to not autoflush when println() is called.
Parameters:
  out - the the OutputStream to provide convenience methods on.
Parameters:
  autoflush - whether to flush when println() is called.



PrintWriter
public PrintWriter(Writer wr)(Code)
Constructs a new PrintWriter on the Writer wr. All writes to the target can now take place through this PrintWriter. By default, the PrintWriter is set to not autoflush when println() is called.
Parameters:
  wr - the Writer to provide convenience methods on.



PrintWriter
public PrintWriter(Writer wr, boolean autoflush)(Code)
Constructs a new PrintWriter on the given writer. All writes to the target can now take place through this PrintWriter. By default, the PrintWriter is set to not autoflush when println() is called.
Parameters:
  wr - the Writer to provide convenience methods on.
Parameters:
  autoflush - whether to flush when println() is called.



PrintWriter
public PrintWriter(File file) throws FileNotFoundException(Code)
Constructs a new PrintWriter on the File file. The automatic flushing is set to false. An intermediate OutputStreamWriter will use the default for the current JVM instance charset to encode characters.
Parameters:
  file - This writer's buffered destination.
throws:
  FileNotFoundException - If there is no such a file or some other error occurs due tothe given file opening.



PrintWriter
public PrintWriter(File file, String csn) throws FileNotFoundException, UnsupportedEncodingException(Code)
Constructs a new PrintWriter on the File file. The automatic flushing is set to false. An intermediate OutputStreamWriter will use a charset with the given name csn to encode characters.
Parameters:
  file - This writer's buffered destination.
Parameters:
  csn - A charset name.
throws:
  FileNotFoundException - If there is no such a file or some other error occurs due tothe given file opening.
throws:
  UnsupportedEncodingException - If a charset with the given name is not supported.



PrintWriter
public PrintWriter(String fileName) throws FileNotFoundException(Code)
Constructs a new PrintWriter on a file with the given file name fileName. The automatic flushing is set to false. An intermediate OutputStreamWriter will use the default for the current JVM instance charset to encode characters.
Parameters:
  fileName - The name of file which is this writer's buffered destination.
throws:
  FileNotFoundException - If there is no such a file or some other error occurs due tothe given file opening.



PrintWriter
public PrintWriter(String fileName, String csn) throws FileNotFoundException, UnsupportedEncodingException(Code)
Constructs a new PrintWriter on a file with the given file name fileName. The automatic flushing is set to false. An intermediate OutputStreamWriter will use a charset with the given name csn to encode characters.
Parameters:
  fileName - The name of file which is this writer's buffered destination.
Parameters:
  csn - A charset name.
throws:
  FileNotFoundException - If there is no such a file or some other error occurs due tothe given file opening.
throws:
  UnsupportedEncodingException - If a charset with the given name is not supported.




Method Detail
append
public PrintWriter append(char c)(Code)
Append a char cto the PrintWriter. The PrintWriter.append(c) works the same way as PrintWriter.write(c).
Parameters:
  c - The character appended to the PrintWriter. The PrintWriter.
See Also:   Writer.append(char)



append
public PrintWriter append(CharSequence csq)(Code)
Append a CharSequence csq to the PrintWriter. The PrintWriter.append(csq) works the same way as PrintWriter.write(csq.toString()). If csq is null, then "null" will be substituted for csq
Parameters:
  csq - The CharSequence appended to the PrintWriter. The PrintWriter
See Also:   Writer.append(CharSequence)



append
public PrintWriter append(CharSequence csq, int start, int end)(Code)
Append a subsequence of a CharSequence csq to the PrintWriter. The first char and the last char of the subsequence is specified by the parameter start and end. The PrintWriter.append(csq) works the same way as PrintWriter.write(csq.subSequence(start,end).toString).If csq is null, then "null" will be substituted for csq.
Parameters:
  csq - The CharSequence appended to the PrintWriter.
Parameters:
  start - The index of the first char in the CharSequence appended tothe PrintWriter.
Parameters:
  end - The index of the char after the last one in the CharSequenceappended to the PrintWriter. The PrintWriter.
throws:
  IndexOutOfBoundsException - If start is less than end, end is greater than the length ofthe CharSequence, or start or end is negative.
See Also:   Writer.append(CharSequenceintint)



checkError
public boolean checkError()(Code)
Answers a boolean indicating whether or not this PrintWriter has encountered an error. If so, the receiver should probably be closed since further writes will not actually take place. A side effect of calling checkError is that the target Writer is flushed. boolean has an error occurred in this PrintWriter.



close
public void close()(Code)
Close this PrintWriter. This implementation flushes and then closes the target writer. If an error occurs, set an error in this PrintWriter to true.



flush
public void flush()(Code)
Flush this PrintWriter to ensure all pending data is sent out to the target Writer. This implementation flushes the target writer. If an error occurs, set an error in this PrintWriter to true.



format
public PrintWriter format(String format, Object... args)(Code)
Writes a string formatted by an intermediate Formatter to this writer using the given format string and arguments. A call to this method flushes the buffered output, if the automatic flushing is enabled.

The method uses the default for the current JVM instance locale, as if it is specified by the Locale.getDefault() call.
Parameters:
  format - A format string.
Parameters:
  args - The arguments list. If there are more arguments than thosespecified by the format string, then the additional argumentsare ignored. This writer.
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:
  NullPointerException - If the given format is null.




format
public PrintWriter format(Locale l, String format, Object... args)(Code)
Writes a string formatted by an intermediate Formatter to this writer using the given format string and arguments. A call to this method flushes the buffered output, if the automatic flushing is enabled.
Parameters:
  l - The locale used in the method. If locale is null, then nolocalization will be applied.
Parameters:
  format - A format string.
Parameters:
  args - The arguments list. If there are more arguments than thosespecified by the format string, then the additional argumentsare ignored. This writer.
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:
  NullPointerException - If the given format is null.



print
public void print(char[] charArray)(Code)
Prints the String representation of the character array parameter charArray to the target Writer.
Parameters:
  charArray - the character array to print on this Writer.



print
public void print(char ch)(Code)
Prints the String representation of the character parameter ch to the target Writer.
Parameters:
  ch - the character to print on this Writer.



print
public void print(double dnum)(Code)
Prints the String representation of the double parameter dnum to the target Writer.
Parameters:
  dnum - the double to print on this Writer.



print
public void print(float fnum)(Code)
Prints the String representation of the float parameter fnum to the target Writer.
Parameters:
  fnum - the float to print on this Writer.



print
public void print(int inum)(Code)
Prints the String representation of the int parameter inum to the target Writer.
Parameters:
  inum - the int to print on this Writer.



print
public void print(long lnum)(Code)
Prints the String representation of the long parameter lnum to the target Writer.
Parameters:
  lnum - the long to print on this Writer.



print
public void print(Object obj)(Code)
Prints the String representation of the Object parameter obj to the target Writer.
Parameters:
  obj - the Object to print on this Writer.



print
public void print(String str)(Code)
Prints the String representation of the String parameter str to the target Writer.
Parameters:
  str - the String to print on this Writer.



print
public void print(boolean bool)(Code)
Prints the String representation of the boolean parameter bool to the target Writer.
Parameters:
  bool - the boolean to print on this Writer.



printf
public PrintWriter printf(String format, Object... args)(Code)
Prints a formatted string. The behavior of this method is the same as this writer's format(String format, Object... args) method.

The method uses the default for the current JVM instance locale, as if it is specified by the Locale.getDefault() call.
Parameters:
  format - A format string.
Parameters:
  args - The arguments list. If there are more arguments than thosespecified by the format string, then the additional argumentsare ignored. This writer.
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:
  NullPointerException - If the given format is null.




printf
public PrintWriter printf(Locale l, String format, Object... args)(Code)
Prints a formatted string. The behavior of this method is the same as this writer's format(Locale l, String format, Object... args) method.
Parameters:
  l - The locale used in the method. If locale is null, then nolocalization will be applied.
Parameters:
  format - A format string.
Parameters:
  args - The arguments list. If there are more arguments than thosespecified by the format string, then the additional argumentsare ignored. the PrintWriter.
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:
  NullPointerException - If the given format is null.



println
public void println()(Code)
Prints the String representation of the System property "line.separator" to the target Writer.



println
public void println(char[] charArray)(Code)
Prints the String representation of the character array parameter charArray to the target Writer followed by the System property "line.separator".
Parameters:
  charArray - the character array to print on this Writer.



println
public void println(char ch)(Code)
Prints the String representation of the character parameter ch to the target Writer followed by the System property "line.separator".
Parameters:
  ch - the character to print on this Writer.



println
public void println(double dnum)(Code)
Prints the String representation of the double parameter dnum to the target Writer followed by the System property "line.separator".
Parameters:
  dnum - the double to print on this Writer.



println
public void println(float fnum)(Code)
Prints the String representation of the float parameter fnum to the target Writer followed by the System property "line.separator".
Parameters:
  fnum - the float to print on this Writer.



println
public void println(int inum)(Code)
Prints the String representation of the int parameter inum to the target Writer followed by the System property "line.separator".
Parameters:
  inum - the int to print on this Writer.



println
public void println(long lnum)(Code)
Prints the String representation of the long parameter lnum to the target Writer followed by the System property "line.separator".
Parameters:
  lnum - the long to print on this Writer.



println
public void println(Object obj)(Code)
Prints the String representation of the Object parameter obj to the target Writer followed by the System property "line.separator".
Parameters:
  obj - the Object to print on this Writer.



println
public void println(String str)(Code)
Prints the String representation of the String parameter str to the target Writer followed by the System property "line.separator".
Parameters:
  str - the String to print on this Writer.



println
public void println(boolean bool)(Code)
Prints the String representation of the boolean parameter bool to the target Writer followed by the System property "line.separator".
Parameters:
  bool - the boolean to print on this Writer.



setError
protected void setError()(Code)
Set the flag indicating that this PrintWriter has encountered an IO error.



write
public void write(char buf)(Code)
Writes the entire character buffer buf to this Writer.
Parameters:
  buf - the non-null array containing characters to write.



write
public void write(char buf, int offset, int count)(Code)
Writes count characters starting at offset in buf to this Writer.
Parameters:
  buf - the non-null array containing characters to write.
Parameters:
  offset - offset in buf to retrieve characters
Parameters:
  count - maximum number of characters to write
throws:
  ArrayIndexOutOfBoundsException - If offset or count are outside of bounds.



write
public void write(int oneChar)(Code)
Writes the specified character to this Writer. This implementation writes the low order two bytes to the target writer.
Parameters:
  oneChar - The character to write



write
public void write(String str)(Code)
Writes the characters from the String str to this Writer.
Parameters:
  str - the non-null String containing the characters to write.



write
public void write(String str, int offset, int count)(Code)
Writes count characters from the String str starting at offset to this Writer.
Parameters:
  str - the non-null String containing the characters to write.
Parameters:
  offset - where in str to get chars from.
Parameters:
  count - how many characters to write.
throws:
  ArrayIndexOutOfBoundsException - If offset or count are outside of bounds.



Fields inherited from java.io.Writer
final static String TOKEN_NULL(Code)(Java Doc)
protected Object lock(Code)(Java Doc)

Methods inherited from java.io.Writer
public Writer append(char c) throws IOException(Code)(Java Doc)
public Writer append(CharSequence csq) throws IOException(Code)(Java Doc)
public Writer append(CharSequence csq, int start, int end) throws IOException(Code)(Java Doc)
abstract public void close() throws IOException(Code)(Java Doc)
abstract public void flush() throws IOException(Code)(Java Doc)
public void write(char buf) throws IOException(Code)(Java Doc)
abstract public void write(char buf, int offset, int count) throws IOException(Code)(Java Doc)
public void write(int oneChar) throws IOException(Code)(Java Doc)
public void write(String str) throws IOException(Code)(Java Doc)
public void write(String str, int offset, int count) throws IOException(Code)(Java Doc)

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.