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
Writer
close
in interface AutoCloseable
close
in class Writer
IOException
public void flush() throws IOException
Writer
flush
in class Writer
IOException
public void write(char[] cbuf, int off, int len) throws IOException
Writer
write
in class Writer
IOException
public void write(String str, int off, int len) throws IOException
Writer
write
in class Writer
IOException
public void write(int c) throws IOException
Writer
write
in class Writer
IOException
public void write(String str) throws IOException
Writer
write
in class Writer
IOException
public void write(char[] cbuf) throws IOException
Writer
write
in class Writer
IOException
public String toString()
Object
public StringBuffer getBuffer()
public StringWriter append(char c)
Appendable
append
in interface Appendable
c
- the character to append.Appendable
.public StringWriter append(CharSequence csq)
Appendable
csq
. 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 Appendable
csq
- the character sequence to append.Appendable
.public StringWriter append(CharSequence csq, int start, int end)
Appendable
csq
.
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 Appendable
csq
- 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
.