home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- import sun.io.ByteToCharConverter;
- import sun.io.ConversionBufferFullException;
-
- public class InputStreamReader extends Reader {
- private ByteToCharConverter btc;
- // $FF: renamed from: in java.io.InputStream
- private InputStream field_0;
- private static final int defaultByteBufferSize = 8192;
- // $FF: renamed from: bb byte[]
- private byte[] field_1;
- private int nBytes;
- private int nextByte;
-
- public InputStreamReader(InputStream var1) {
- this(var1, ByteToCharConverter.getDefault());
- }
-
- public InputStreamReader(InputStream var1, String var2) throws UnsupportedEncodingException {
- this(var1, ByteToCharConverter.getConverter(var2));
- }
-
- private InputStreamReader(InputStream var1, ByteToCharConverter var2) {
- super(var1);
- this.field_0 = var1;
- this.btc = var2;
- this.field_1 = new byte[8192];
- }
-
- public String getEncoding() {
- Object var2 = super.lock;
- synchronized(var2){}
-
- String var1;
- try {
- if (this.btc == null) {
- var1 = null;
- return var1;
- }
-
- var1 = this.btc.getCharacterEncoding();
- } catch (Throwable var5) {
- throw var5;
- }
-
- return var1;
- }
-
- private void malfunction() {
- throw new InternalError("Converter malfunction (" + this.btc.getCharacterEncoding() + ") -- please submit a bug report via " + System.getProperty("java.vendor.url.bug"));
- }
-
- private int convertInto(char[] var1, int var2, int var3) throws IOException {
- int var4 = 0;
- if (this.nextByte < this.nBytes) {
- try {
- var4 = this.btc.convert(this.field_1, this.nextByte, this.nBytes, var1, var2, var3);
- this.nextByte = this.nBytes;
- if (this.btc.nextByteIndex() != this.nextByte) {
- this.malfunction();
- }
- } catch (ConversionBufferFullException var5) {
- this.nextByte = this.btc.nextByteIndex();
- var4 = this.btc.nextCharIndex() - var2;
- }
- }
-
- return var4;
- }
-
- private int flushInto(char[] var1, int var2, int var3) throws IOException {
- int var4 = 0;
-
- try {
- var4 = this.btc.flush(var1, var2, var3);
- } catch (ConversionBufferFullException var5) {
- var4 = this.btc.nextCharIndex() - var2;
- }
-
- return var4;
- }
-
- private int fill(char[] var1, int var2, int var3) throws IOException {
- int var4 = 0;
- if (this.nextByte < this.nBytes) {
- var4 = this.convertInto(var1, var2, var3);
- }
-
- while(var2 + var4 < var3) {
- if (this.nBytes != -1) {
- if (var4 > 0 && !this.inReady()) {
- break;
- }
-
- this.nBytes = this.field_0.read(this.field_1);
- }
-
- if (this.nBytes == -1) {
- var4 += this.flushInto(var1, var2 + var4, var3);
- if (var4 == 0) {
- return -1;
- }
- break;
- }
-
- this.nextByte = 0;
- var4 += this.convertInto(var1, var2 + var4, var3);
- }
-
- return var4;
- }
-
- private boolean inReady() {
- try {
- return this.field_0.available() > 0;
- } catch (IOException var1) {
- return false;
- }
- }
-
- private void ensureOpen() throws IOException {
- if (this.field_0 == null) {
- throw new IOException("Stream closed");
- }
- }
-
- public int read() throws IOException {
- char[] var1 = new char[1];
- return this.read(var1, 0, 1) == -1 ? -1 : var1[0];
- }
-
- public int read(char[] var1, int var2, int var3) throws IOException {
- Object var5 = super.lock;
- synchronized(var5){}
-
- int var4;
- try {
- this.ensureOpen();
- var4 = this.fill(var1, var2, var2 + var3);
- } catch (Throwable var8) {
- throw var8;
- }
-
- return var4;
- }
-
- public boolean ready() throws IOException {
- Object var2 = super.lock;
- synchronized(var2){}
-
- boolean var1;
- try {
- this.ensureOpen();
- var1 = this.nextByte < this.nBytes || this.inReady();
- } catch (Throwable var5) {
- throw var5;
- }
-
- return var1;
- }
-
- public void close() throws IOException {
- Object var1 = super.lock;
- synchronized(var1){}
-
- try {
- if (this.field_0 != null) {
- this.field_0.close();
- this.field_0 = null;
- this.field_1 = null;
- this.btc = null;
- return;
- }
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
- }
-