Java Reference
In-Depth Information
public String
toString(String enc)
tHRows UnsupportedEncodingExcep-
tion
Returns the current contents of the buffer as a
String
, trans-
lating bytes into characters according to the specified char-
acter encoding. If the encoding is not supported an
Unsuppor-
tedEncodingException
is thrown.
public void
writeTo(OutputStream out)
throws IOException
Writes the current contents of the buffer to the stream
out
.
20.5.6.
CharArray
Character Streams
The
CharArray
character streams are analogous to the
ByteArray
byte
streamsthey let you use
char
arrays as a source or destination without
ever blocking. You construct
CharArrayReader
objects with an array of
char
:
public
CharArrayReader(char[] buf, int offset, int count)
Creates a
CharArrayReader
from the specified array of char-
acters using only the subarray of
buf
from
buf[offset]
to
buf[offset+count-1]
or the end of the array, whichever is smal-
ler. The input array is used directly, not copied, so you should
take care not to modify it while it is being used as an input
source.
public
CharArrayReader(char[] buf)
Equivalent to
CharArrayReader(buf,0, buf.length)
.
The
CharArrayWriter
class provides a dynamically growing
char
array to
hold output. It adds constructors and methods: