| java.lang.Object java.io.Writer java.io.StringWriter
StringWriter | public class StringWriter extends Writer (Code) | | StringWriter is an class for writing Character Streams to a StringBuffer. The
characters written can then be returned as a String. This is used for
capturing output sent to a Writer by substituting a StringWriter.
See Also: StringReader |
Constructor Summary | |
public | StringWriter() Constructs a new StringWriter which has a StringBuffer allocated with the
default size of 16 characters. | public | StringWriter(int initialSize) Constructs a new StringWriter which has a StringBuffer allocated with the
size of initialSize characters. |
Method Summary | |
public StringWriter | append(char c) Append a char c to the StringWriter. | public StringWriter | append(CharSequence csq) Append a CharSequence csq to the StringWriter. | public StringWriter | append(CharSequence csq, int start, int end) Append a subsequence of a CharSequence csq to the
StringWriter. | public void | close() Close this Writer. | public void | flush() Flush this Writer. | public StringBuffer | getBuffer() Answer the contents of this StringWriter as a StringBuffer. | public String | toString() Answer the contents of this StringWriter as a String. | public void | write(char[] cbuf, int offset, int count) Writes count characters starting at offset
in cbuf to this StringWriter. | public void | write(int oneChar) Writes the specified character oneChar to this
StringWriter. | public void | write(String str) Writes the characters from the String str to this
StringWriter. | public void | write(String str, int offset, int count) Writes count number of characters starting at
offset from the String str to this
StringWriter. |
StringWriter | public StringWriter()(Code) | | Constructs a new StringWriter which has a StringBuffer allocated with the
default size of 16 characters. The StringBuffer is also the
lock used to synchronize access to this Writer.
|
StringWriter | public StringWriter(int initialSize)(Code) | | Constructs a new StringWriter which has a StringBuffer allocated with the
size of initialSize characters. The StringBuffer is also
the lock used to synchronize access to this Writer.
Parameters: initialSize - the intial number of characters |
append | public StringWriter append(char c)(Code) | | Append a char c to the StringWriter. The
StringWriter.append(c ) works the same way as
StringWriter.write(c ).
Parameters: c - The character appended to the StringWriter. The StringWriter. |
append | public StringWriter append(CharSequence csq)(Code) | | Append a CharSequence csq to the StringWriter. The
StringWriter.append(csq ) works the same way as
StringWriter.write(csq .toString()). If csq
is null, then "null" will be substituted for csq .
Parameters: csq - The CharSequence appended to the StringWriter. The StringWriter |
append | public StringWriter append(CharSequence csq, int start, int end)(Code) | | Append a subsequence of a CharSequence csq to the
StringWriter. The first char and the last char of the subsequnce is
specified by the parameter start and end .
The StringWriter.append(csq ) works the same way as
StringWriter.write(csq .subSequence(start ,end ).toString).If
csq is null, then "null" will be substituted for
csq . s
Parameters: csq - The CharSequence appended to the StringWriter. Parameters: start - The index of the first char in the CharSequence appended tothe StringWriter. Parameters: end - The index of the char after the last one in the CharSequenceappended to the StringWriter. The StringWriter. throws: IndexOutOfBoundsException - If start is less than end, end is greater than the length ofthe CharSequence, or start or end is negative. |
close | public void close() throws IOException(Code) | | Close this Writer. This is the concrete implementation required. This
particular implementation does nothing.
throws: IOException - If an IO error occurs closing this StringWriter. |
flush | public void flush()(Code) | | Flush this Writer. This is the concrete implementation required. This
particular implementation does nothing.
|
getBuffer | public StringBuffer getBuffer()(Code) | | Answer the contents of this StringWriter as a StringBuffer. Any changes
made to the StringBuffer by the receiver or the caller are reflected in
this StringWriter.
this StringWriters local StringBuffer. |
toString | public String toString()(Code) | | Answer the contents of this StringWriter as a String. Any changes made to
the StringBuffer by the receiver after returning will not be reflected in
the String returned to the caller.
this StringWriters current contents as a String. |
write | public void write(char[] cbuf, int offset, int count)(Code) | | Writes count characters starting at offset
in cbuf to this StringWriter.
Parameters: cbuf - 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 oneChar to this
StringWriter. This implementation writes the low order two bytes to the
Stream.
Parameters: oneChar - The character to write |
write | public void write(String str)(Code) | | Writes the characters from the String str to this
StringWriter.
Parameters: str - the non-null String containing the characters to write. |
write | public void write(String str, int offset, int count)(Code) | | Writes count number of characters starting at
offset from the String str to this
StringWriter.
Parameters: str - the non-null String containing the characters to write. Parameters: offset - the starting point to retrieve characters. Parameters: count - the number of characters to retrieve and write. throws: ArrayIndexOutOfBoundsException - If offset or count are outside of bounds. |
|
|