2009-03-15 18:02:36 +00:00
|
|
|
/* Copyright (c) 2008-2009, Avian Contributors
|
2008-02-19 18:06:52 +00:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
|
|
for any purpose with or without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice appear
|
|
|
|
in all copies.
|
|
|
|
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
|
|
details. */
|
|
|
|
|
2007-07-29 01:29:01 +00:00
|
|
|
package java.io;
|
|
|
|
|
|
|
|
public class InputStreamReader extends Reader {
|
|
|
|
private final InputStream in;
|
|
|
|
|
|
|
|
public InputStreamReader(InputStream in) {
|
|
|
|
this.in = in;
|
|
|
|
}
|
2009-02-17 01:22:19 +00:00
|
|
|
|
|
|
|
public InputStreamReader(InputStream in, String encoding)
|
|
|
|
throws UnsupportedEncodingException
|
|
|
|
{
|
|
|
|
this(in);
|
|
|
|
|
|
|
|
if (! encoding.equals("UTF-8")) {
|
|
|
|
throw new UnsupportedEncodingException(encoding);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-29 01:29:01 +00:00
|
|
|
|
|
|
|
public int read(char[] b, int offset, int length) throws IOException {
|
|
|
|
byte[] buffer = new byte[length];
|
|
|
|
int c = in.read(buffer);
|
|
|
|
for (int i = 0; i < c; ++i) {
|
|
|
|
b[i + offset] = (char) buffer[i];
|
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void close() throws IOException {
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
}
|