11 import java.io.CharConversionException;
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.io.Reader;
79 _bytes =
new byte[capacity];
97 throw new IllegalStateException(
"Reader not closed or reset");
109 public boolean ready() throws IOException {
111 throw new IOException(
"Stream closed");
120 public void close() throws IOException {
135 public int read() throws IOException {
141 private int read2() throws IOException {
149 }
else if (((b & 0xc0) == 0x80) && (
_moreBytes != 0)) {
157 }
else if (((b & 0xe0) == 0xc0) && (
_moreBytes == 0)) {
162 }
else if (((b & 0xf0) == 0xe0) && (
_moreBytes == 0)) {
167 }
else if (((b & 0xf8) == 0xf0) && (
_moreBytes == 0)) {
172 }
else if (((b & 0xfc) == 0xf8) && (
_moreBytes == 0)) {
177 }
else if (((b & 0xfe) == 0xfc) && (
_moreBytes == 0)) {
183 throw new CharConversionException(
"Invalid UTF-8 Encoding");
187 throw new IOException(
"No input stream or stream closed");
196 throw new CharConversionException(
197 "Unexpected end of stream");
222 public int read(
char cbuf[],
int off,
int len)
throws IOException {
224 throw new IOException(
"No input stream or stream closed");
232 final int off_plus_len = off + len;
233 for (
int i = off; i < off_plus_len;) {
237 cbuf[i++] = (char) b;
239 if (i < off_plus_len - 1) {
241 if (code < 0x10000) {
242 cbuf[i++] = (char) code;
243 }
else if (code <= 0x10ffff) {
244 cbuf[i++] = (char) (((code - 0x10000) >> 10) + 0xd800);
245 cbuf[i++] = (char) (((code - 0x10000) & 0x3ff) + 0xdc00);
247 throw new CharConversionException(
"Cannot convert U+"
248 + Integer.toHexString(code)
249 +
" to char (code greater than U+10FFFF)");
257 cbuf[i++] = (char) b;
271 public void read(Appendable dest)
throws IOException {
273 throw new IOException(
"No input stream or stream closed");
284 dest.append((
char) b);
288 if (code < 0x10000) {
289 dest.append((
char) code);
290 }
else if (code <= 0x10ffff) {
291 dest.append((
char) (((code - 0x10000) >> 10) + 0xd800));
292 dest.append((
char) (((code - 0x10000) & 0x3ff) + 0xdc00));
294 throw new CharConversionException(
"Cannot convert U+"
295 + Integer.toHexString(code)
296 +
" to char (code greater than U+10FFFF)");