Save This Page
Home » apache-harmony-6.0-src-r917296-snapshot » java » io » [javadoc | source]
java.io
public class: StringWriter [javadoc | source]
java.lang.Object
   java.io.Writer
      java.io.StringWriter

All Implemented Interfaces:
    Flushable, Closeable, Appendable

A specialized Writer that writes characters to a {@code StringBuffer} in a sequential manner, appending them in the process. The result can later be queried using the #StringWriter(int) or #toString() methods.
Fields inherited from java.io.Writer:
TOKEN_NULL,  lock
Constructor:
 public StringWriter() 
 public StringWriter(int initialSize) 
    Parameters:
    initialSize - the intial size of the target string buffer.
Method from java.io.StringWriter Summary:
append,   append,   append,   close,   flush,   getBuffer,   toString,   write,   write,   write,   write
Methods from java.io.Writer:
append,   append,   append,   checkError,   close,   flush,   write,   write,   write,   write,   write
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.io.StringWriter Detail:
 public StringWriter append(char c) 
    Appends the character {@code c} to this writer's {@code StringBuffer}. This method works the same way as #write(int) .
 public StringWriter append(CharSequence csq) 
    Appends the character sequence {@code csq} to this writer's {@code StringBuffer}. This method works the same way as {@code StringWriter.write(csq.toString())}. If {@code csq} is {@code null}, then the string "null" is written to the target stream.
 public StringWriter append(CharSequence csq,
    int start,
    int end) 
    Appends a subsequence of the character sequence {@code csq} to this writer's {@code StringBuffer}. This method works the same way as {@code StringWriter.writer(csq.subsequence(start, end).toString())}. If {@code csq} is {@code null}, then the specified subsequence of the string "null" will be written to the target.
 public  void close() throws IOException 
    Calling this method has no effect. In contrast to most {@code Writer} subclasses, the other methods in {@code StringWriter} do not throw an {@code IOException} if {@code close()} has been called.
 public  void flush() 
    Calling this method has no effect.
 public StringBuffer getBuffer() 
    Gets a reference to this writer's internal StringBuffer . Any changes made to the returned buffer are reflected in this writer.
 public String toString() 
    Gets a copy of the contents of this writer as a string.
 public  void write(int oneChar) 
    Writes one character to this writer's {@code StringBuffer}. Only the two least significant bytes of the integer {@code oneChar} are written.
 public  void write(String str) 
    Writes the characters from the specified string to this writer's {@code StringBuffer}.
 public  void write(char[] cbuf,
    int offset,
    int count) 
    Writes {@code count} characters starting at {@code offset} in {@code buf} to this writer's {@code StringBuffer}.
 public  void write(String str,
    int offset,
    int count) 
    Writes {@code count} characters from {@code str} starting at {@code offset} to this writer's {@code StringBuffer}.