|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.io.Writer
java.io.CharArrayWriter
public class CharArrayWriter
CharArrayWriter is used as a character output stream on a character array. The buffer used to store the written characters will grow as needed to accomodate more characters as they are written.
| Field Summary | |
|---|---|
protected char[] |
buf
Buffer for characters |
protected int |
count
The ending index of the buffer. |
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
CharArrayWriter()
Constructs a new CharArrayWriter which has a buffer allocated with the default size of 32 characters. |
|
CharArrayWriter(int initialSize)
Constructs a new CharArrayWriter which has a buffer allocated with the size of initialSize characters. |
|
| Method Summary | |
|---|---|
CharArrayWriter |
append(char c)
Appends the given character to the contents of the receiver. |
CharArrayWriter |
append(CharSequence sequence)
Appends the given character sequence to the contents of the receiver. |
CharArrayWriter |
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. |
void |
reset()
Reset this Writer. |
int |
size()
Answer the size of this Writer in characters. |
char[] |
toCharArray()
Answer the contents of the receiver as a char array. |
String |
toString()
Answer the contents of this CharArrayWriter as a String. |
void |
write(char[] buffer,
int offset,
int length)
Writes length characters starting at offset
in buffer to this CharArrayWriter. |
void |
write(int oneChar)
Writes the specified character oneChar to this CharArrayWriter. |
void |
write(String str,
int offset,
int length)
Writes length number of characters starting at offset from the
String str to this CharArrayWriter. |
void |
writeTo(Writer out)
Writes the contents of this CharArrayWriter to another Writer. |
| Methods inherited from class java.io.Writer |
|---|
write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected char[] buf
protected int count
| Constructor Detail |
|---|
public CharArrayWriter()
lock used to synchronize access to this Writer.
public CharArrayWriter(int initialSize)
initialSize characters. The buffer is
also the lock used to synchronize access to this Writer.
initialSize - the initial size of this CharArrayWriters buffer.| Method Detail |
|---|
public void close()
close in interface Closeableclose in class Writerpublic void flush()
flush in interface Flushableflush in class Writerpublic void reset()
public int size()
public char[] toCharArray()
public String toString()
toString in class Objectpublic void write(char[] buffer,
int offset,
int length)
length characters starting at offset
in buffer to this CharArrayWriter.
write in class Writerbuffer - the non-null array containing characters to write.offset - offset in buf to retrieve characterslength - maximum number of characters to writepublic void write(int oneChar)
oneChar to this CharArrayWriter. This
implementation writes the low order two bytes to the Stream.
write in class WriteroneChar - The character to writepublic void write(String str,
int offset,
int length)
length number of characters starting at offset from the
String str to this CharArrayWriter.
write in class Writerstr - the non-null String containing the characters to write.offset - the starting point to retrieve characters.length - the number of characters to retrieve and write.public void writeTo(Writer out)
throws IOException
out - the non-null Writer on which to write the contents.
IOException - If an error occurs attempting to write the contents out.public CharArrayWriter append(char c)
Appendable
append in interface Appendableappend in class Writerc - the character to append
Appendable.append(char)public CharArrayWriter 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 CharArrayWriter 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 | |||||||