Class StringWriter
java.lang.Object
java.io.Writer
java.io.StringWriter
- All Implemented Interfaces:
java.lang.Appendable, java.lang.AutoCloseable
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(java.lang.CharSequence csq) append(java.lang.CharSequence csq, int start, int end) voidclose()Close the stream, flushing it first.voidflush()Flush the stream.java.lang.StringBufferjava.lang.StringtoString()voidwrite(char[] cbuf) Write an array of characters.voidwrite(char[] cbuf, int off, int len) Write a portion of an array of characters.voidwrite(int c) Write a single character.voidwrite(java.lang.String str) Write a string.voidwrite(java.lang.String str, int off, int len) Write a portion of a string.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
StringWriter
public StringWriter() -
StringWriter
public StringWriter(int initialSize)
-
-
Method Details
-
close
Description copied from class:WriterClose the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein classWriter- Throws:
IOException
-
flush
Description copied from class:WriterFlush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.- Specified by:
flushin classWriter- Throws:
IOException
-
write
Description copied from class:WriterWrite a portion of an array of characters.- Specified by:
writein classWriter- Throws:
IOException
-
write
Description copied from class:WriterWrite a portion of a string.- Overrides:
writein classWriter- Throws:
IOException
-
write
Description copied from class:WriterWrite a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored. Subclasses that intend to support efficient single-character output should override this method.- Overrides:
writein classWriter- Throws:
IOException
-
write
Description copied from class:WriterWrite a string.- Overrides:
writein classWriter- Throws:
IOException
-
write
Description copied from class:WriterWrite an array of characters.- Overrides:
writein classWriter- Throws:
IOException
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getBuffer
public java.lang.StringBuffer getBuffer() -
append
- Specified by:
appendin interfacejava.lang.Appendable
-
append
- Specified by:
appendin interfacejava.lang.Appendable
-
append
- Specified by:
appendin interfacejava.lang.Appendable
-