Closeable
, Flushable
, Appendable
, AutoCloseable
Note: Invoking close() on this class has no effect, and methods of this class can be called after the stream has closed without generating an IOException.
Fields
protected char[]
The buffer where data is stored.
protected int
The number of chars in the buffer.
Constructors
Creates a new CharArrayWriter.
Creates a new CharArrayWriter with the specified initial size.
Appends the specified character to this writer.
Appends the specified character sequence to this writer.
Appends a subsequence of the specified character sequence to this writer.
void
void
void
Resets the buffer so that you can use it again without throwing away the already allocated buffer.
int
Returns the current size of the buffer.
char[]
Returns a copy of the input data.
Converts input data to a string.
void
write(char[] c, int off, int len)
Writes characters to the buffer.
void
Writes a character to the buffer.
void
Write a portion of a string to the buffer.
void
Writes the contents of the buffer to another character stream.
protected char[] buf
The buffer where data is stored.
protected int count
The number of chars in the buffer.
public CharArrayWriter()
Creates a new CharArrayWriter.
public CharArrayWriter(int initialSize)
Creates a new CharArrayWriter with the specified initial size.
initialSize
- an int specifying the initial buffer size.
IllegalArgumentException
- if initialSize is negative
public void write(int c)
Writes a character to the buffer.
public void write(char[] c, int off, int len)
Writes characters to the buffer.
write
in class Writer
c
- the data to be written
off
- the start offset in the data
len
- the number of chars that are written
IndexOutOfBoundsException
- If off
is negative, or len
is negative, or off + len
is negative or greater than the length of the given array
Write a portion of a string to the buffer.
write
in class Writer
str
- String to be written from
off
- Offset from which to start reading characters
len
- Number of characters to be written
IndexOutOfBoundsException
- If off
is negative, or len
is negative, or off + len
is negative or greater than the length of the given string
Writes the contents of the buffer to another character stream.
out
- the output stream to write to
IOException
- If an I/O error occurs.
Appends the specified character sequence to this writer.
An invocation of this method of the form out.append(csq)
behaves in exactly the same way as the invocation
out.write(csq.toString())
Depending on the specification of toString
for the character sequence csq
, the entire sequence may not be appended. For instance, invoking the toString
method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.
append
in interface Appendable
append
in class Writer
csq
- The character sequence to append. If csq
is null
, then the four characters "null"
are appended to this writer.
Appends a subsequence of the specified character sequence to this writer.
An invocation of this method of the form out.append(csq, start, end)
when csq
is not null
, behaves in exactly the same way as the invocation
out.write(csq.subSequence(start, end).toString())
append
in interface Appendable
append
in class Writer
csq
- The character sequence from which a subsequence will be appended. If csq
is null
, then characters will be appended as if csq
contained the four characters "null"
.
start
- The index of the first character in the subsequence
end
- The index of the character following the last character in the subsequence
IndexOutOfBoundsException
- If start
or end
are negative, start
is greater than end
, or end
is greater than csq.length()
Appends the specified character to this writer.
An invocation of this method of the form out.append(c)
behaves in exactly the same way as the invocation
append
in interface Appendable
append
in class Writer
c
- The 16-bit character to append
public void reset()
Resets the buffer so that you can use it again without throwing away the already allocated buffer.
public char[] toCharArray()
Returns a copy of the input data.
public int size()
Returns the current size of the buffer.
Converts input data to a string.
public void flush()
The flush
method of CharArrayWriter
does nothing.
public void close()
Close the stream. This method does not release the buffer, since its contents might still be required. Note: Invoking this method in this class will have no effect.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4