public class StringWriter extends Writer implements Appendable
| Constructor and Description |
|---|
StringWriter() |
StringWriter(int initialSize) |
| Modifier and Type | Method and Description |
|---|---|
StringWriter |
append(char c)
Appends the specified character.
|
StringWriter |
append(CharSequence csq)
Appends the character sequence
csq. |
StringWriter |
append(CharSequence csq,
int start,
int end)
Appends a subsequence of
csq. |
void |
close()
Close the stream, flushing it first.
|
void |
flush()
Flush the stream.
|
StringBuffer |
getBuffer() |
String |
toString()
Returns a string representation of the object.
|
void |
write(char[] cbuf)
Write an array of characters.
|
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters.
|
void |
write(int c)
Write a single character.
|
void |
write(String str)
Write a string.
|
void |
write(String str,
int off,
int len)
Write a portion of a string.
|
public StringWriter()
public StringWriter(int initialSize)
public void close()
throws IOException
Writerclose in interface AutoCloseableclose in class WriterIOExceptionpublic void flush()
throws IOException
Writerflush in class WriterIOExceptionpublic void write(char[] cbuf,
int off,
int len)
throws IOException
Writerwrite in class WriterIOExceptionpublic void write(String str, int off, int len) throws IOException
Writerwrite in class WriterIOExceptionpublic void write(int c)
throws IOException
Writerwrite in class WriterIOExceptionpublic void write(String str) throws IOException
Writerwrite in class WriterIOExceptionpublic void write(char[] cbuf)
throws IOException
Writerwrite in class WriterIOExceptionpublic String toString()
Objectpublic StringBuffer getBuffer()
public StringWriter append(char c)
Appendableappend in interface Appendablec - the character to append.Appendable.public StringWriter append(CharSequence csq)
Appendablecsq. Implementation classes may
not append the whole sequence, for example if the target is a buffer with
limited size.
If csq is null, the characters "null" are appended.
append in interface Appendablecsq - the character sequence to append.Appendable.public StringWriter append(CharSequence csq, int start, int end)
Appendablecsq.
If csq is not null then calling this method is equivalent
to calling append(csq.subSequence(start, end)).
If csq is null, the characters "null" are appended.
append in interface Appendablecsq - the character sequence to append.start - the first index of the subsequence of csq that is
appended.end - the last index of the subsequence of csq that is
appended.Appendable.