Class: java.io.StringWriter
- public class StringWriter
- extends Writer
Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
Methods
-
StringWritertop
public StringWriter()Create a new string writer using the default initial string-buffer size. -
StringWritertop
public StringWriter(int initialSize)Create a new string writer using the specified initial string-buffer size. -
appendtop
public StringWriter append(char c)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)- Specified by:
- append from Appendable
-
appendtop
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. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.
- Specified by:
- append from Appendable
-
appendtop
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())- Specified by:
- append from Appendable
-
closetop
public void close() throws IOExceptionClosing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException. -
flushtop
public void flush()Flush the stream. -
getBuffertop
public StringBuffer getBuffer()Return the string buffer itself. -
toStringtop
public String toString()Return the buffer's current value as a string. -
writetop
public void write(int c)Write a single character. -
writetop
public void write(String str)Write a string. -
writetop
public void write(String str, int off, int len)Write a portion of a string. -
writetop
public void write(char[] cbuf, int off, int len)Write a portion of an array of characters.
