|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.io.Writer
java.io.StringWriter
public class StringWriter
StringWriter is an class for writing Character Streams to a StringBuffer. The characters written can then be returned as a String. This is used for capturing output sent to a Writer by substituting a StringWriter.
StringReader| Field Summary |
|---|
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
StringWriter()
Constructs a new StringWriter which has a StringBuffer allocated with the default size of 16 characters. |
|
StringWriter(int initialSize)
Constructs a new StringWriter which has a StringBuffer allocated with the size of initialSize characters. |
|
| Method Summary | |
|---|---|
StringWriter |
append(char c)
Appends the given character to the contents of the receiver. |
StringWriter |
append(CharSequence sequence)
Appends the given character sequence to the contents of the receiver. |
StringWriter |
append(CharSequence sequence,
int start,
int stop)
Appends the given character sequence to the contents of the receiver. |
void |
close()
Close this Writer. |
void |
flush()
Flush this Writer. |
StringBuffer |
getBuffer()
Answer the contents of this StringWriter as a StringBuffer. |
String |
toString()
Answer the contents of this StringWriter as a String. |
void |
write(char[] buffer,
int offset,
int count)
Writes count characters starting at offset
in buffer to this StringWriter. |
void |
write(int oneChar)
Writes the specified character oneChar to this StringWriter. |
void |
write(String str)
Writes the characters from the String str to this StringWriter. |
void |
write(String str,
int offset,
int count)
Writes count number of characters starting at offset from the
String str to this StringWriter. |
| Methods inherited from class java.io.Writer |
|---|
write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public StringWriter()
lock used to synchronize access to this Writer.
public StringWriter(int initialSize)
initialSize characters. The StringBuffer is also
the lock used to synchronize access to this Writer.
initialSize - the intial number of characters| Method Detail |
|---|
public void close()
throws IOException
close in interface Closeableclose in class WriterIOException - If an IO error occurs closing this StringWriter.public void flush()
flush in interface Flushableflush in class Writerpublic StringBuffer getBuffer()
public String toString()
toString in class Objectpublic void write(char[] buffer,
int offset,
int count)
count characters starting at offset
in buffer to this StringWriter.
write in class Writerbuffer - the non-null array containing characters to write.offset - offset in buf to retrieve characterscount - maximum number of characters to write
ArrayIndexOutOfBoundsException - If offset or count are outside of bounds.public void write(int oneChar)
oneChar to this StringWriter. This implementation writes
the low order two bytes to the Stream.
write in class WriteroneChar - The character to writepublic void write(String str)
str to this StringWriter.
write in class Writerstr - the non-null String containing the characters to write.public void write(String str,
int offset,
int count)
count number of characters starting at offset from the
String str to this StringWriter.
write in class Writerstr - the non-null String containing the characters to write.offset - the starting point to retrieve characters.count - the number of characters to retrieve and write.
ArrayIndexOutOfBoundsException - If offset or count are outside of bounds.public StringWriter append(char c)
Appendable
append in interface Appendableappend in class Writerc - the character to append
Appendable.append(char)public StringWriter append(CharSequence sequence)
Appendable
append in interface Appendableappend in class Writersequence - the character sequence to append, if null then
the String "null" is appended
Appendable.append(java.lang.CharSequence)public StringWriter append(CharSequence sequence,
int start,
int stop)
Appendable
append in interface Appendableappend in class Writersequence - the character sequence to append, if null then
the String "null" is appendedstart - the offset of the first characterstop - the offset one past the last character
Appendable.append(java.lang.CharSequence, int, int)
|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||