StringWriter class methods in Java

java.io.StringWriter

A character stream 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.

Implemented Interfaces:

Closeable

Flushable

Appendable

AutoCloseable

Some methods of StringWriter class

append(char)This method appends the specified character to this writer.

append(CharSequence)This method appends the specified character sequence to this writer.

append(CharSequence, int, int)This method appends a subsequence of the specified character sequence to this writer.

close()This method closes a StringWriter.

flush()This method flushes the stream.

getBuffer()This method returns the string buffer itself.

StringWriter()This method creates a new string writer using the default initial string buffer size.

StringWriter(int)This method creates a new string writer using the specified initial string buffer size.

toString()This method returns the buffer's current value as a string.

write(int)This method writes a single character.

write(String)This method writes a string.

write(char[], int, int)This method writes a portion of an array of characters.

write(String, int, int)This method writes a portion of a string.

No comments:

Post a Comment