| java.lang.Object java.io.Writer java.io.StringWriter
StringWriter | public class StringWriter extends Writer (Code) | | A character stream that collects its output in a string buffer, which can
then be used to construct a string.
Closing a StringWriter has no effect. The methods in this class
can be called after the stream has been closed without generating an
IOException.
version: 1.32, 07/05/05 author: Mark Reinhold since: JDK1.1 |
Constructor Summary | |
public | StringWriter() Create a new string writer using the default initial string-buffer
size. | public | StringWriter(int initialSize) Create a new string writer using the specified initial string-buffer
size. |
Method Summary | |
public StringWriter | append(CharSequence csq) Appends the specified character sequence to this writer.
An invocation of this method of the form out.append(csq)
behaves in exactly the same way as the invocation
out.write(csq.toString())
Depending on the specification of toString for the
character sequence csq, the entire sequence may not be
appended. | public StringWriter | append(CharSequence csq, int start, int end) Appends a subsequence of the specified character sequence to this writer.
An invocation of this method of the form out.append(csq, start,
end) when csq is not null, behaves in
exactly the same way as the invocation
out.write(csq.subSequence(start, end).toString())
Parameters: csq - The character sequence from which a subsequence will beappended. | public StringWriter | append(char c) Appends the specified character to this writer. | public void | close() Closing a StringWriter has no effect. | public void | flush() Flush the stream. | public StringBuffer | getBuffer() Return the string buffer itself. | public String | toString() Return the buffer's current value as a string. | public void | write(int c) Write a single character. | public void | write(char cbuf, int off, int len) Write a portion of an array of characters. | public void | write(String str) Write a string. | public void | write(String str, int off, int len) Write a portion of a string. |
StringWriter | public StringWriter()(Code) | | Create a new string writer using the default initial string-buffer
size.
|
StringWriter | public StringWriter(int initialSize)(Code) | | Create a new string writer using the specified initial string-buffer
size.
Parameters: initialSize - The number of char values that will fit into this bufferbefore it is automatically expanded throws: IllegalArgumentException - If initialSize is negative |
append | public StringWriter append(CharSequence csq)(Code) | | Appends the specified character sequence to this writer.
An invocation of this method of the form out.append(csq)
behaves in exactly the same way as the invocation
out.write(csq.toString())
Depending on the specification of toString for the
character sequence csq, the entire sequence may not be
appended. For instance, invoking the toString method of a
character buffer will return a subsequence whose content depends upon
the buffer's position and limit.
Parameters: csq - The character sequence to append. If csq isnull, then the four characters "null" areappended to this writer. This writer since: 1.5 |
append | public StringWriter append(CharSequence csq, int start, int end)(Code) | | Appends a subsequence of the specified character sequence to this writer.
An invocation of this method of the form out.append(csq, start,
end) when csq is not null, behaves in
exactly the same way as the invocation
out.write(csq.subSequence(start, end).toString())
Parameters: csq - The character sequence from which a subsequence will beappended. If csq is null, then characterswill be appended as if csq contained the fourcharacters "null". Parameters: start - The index of the first character in the subsequence Parameters: end - The index of the character following the last character in thesubsequence This writer throws: IndexOutOfBoundsException - If start or end are negative, startis greater than end, or end is greater thancsq.length() since: 1.5 |
append | public StringWriter append(char c)(Code) | | Appends the specified character to this writer.
An invocation of this method of the form out.append(c)
behaves in exactly the same way as the invocation
out.write(c)
Parameters: c - The 16-bit character to append This writer since: 1.5 |
close | public void close() throws IOException(Code) | | Closing a StringWriter has no effect. The methods in this
class can be called after the stream has been closed without generating
an IOException.
|
flush | public void flush()(Code) | | Flush the stream.
|
getBuffer | public StringBuffer getBuffer()(Code) | | Return the string buffer itself.
StringBuffer holding the current buffer value. |
toString | public String toString()(Code) | | Return the buffer's current value as a string.
|
write | public void write(int c)(Code) | | Write a single character.
|
write | public void write(char cbuf, int off, int len)(Code) | | Write a portion of an array of characters.
Parameters: cbuf - Array of characters Parameters: off - Offset from which to start writing characters Parameters: len - Number of characters to write |
write | public void write(String str, int off, int len)(Code) | | Write a portion of a string.
Parameters: str - String to be written Parameters: off - Offset from which to start writing characters Parameters: len - Number of characters to write |
|
|