home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- public class BufferedReader extends Reader {
- // $FF: renamed from: in java.io.Reader
- private Reader field_0;
- // $FF: renamed from: cb char[]
- private char[] field_1;
- private int nChars;
- private int nextChar;
- private static final int INVALIDATED = -2;
- private static final int UNMARKED = -1;
- private int markedChar;
- private int readAheadLimit;
- private static int defaultCharBufferSize = 8192;
- private static int defaultExpectedLineLength = 80;
-
- public BufferedReader(Reader var1, int var2) {
- super(var1);
- this.markedChar = -1;
- if (var2 <= 0) {
- throw new IllegalArgumentException("Buffer size <= 0");
- } else {
- this.field_0 = var1;
- this.field_1 = new char[var2];
- this.nextChar = this.nChars = 0;
- }
- }
-
- public BufferedReader(Reader var1) {
- this(var1, defaultCharBufferSize);
- }
-
- private void ensureOpen() throws IOException {
- if (this.field_0 == null) {
- throw new IOException("Stream closed");
- }
- }
-
- private void fill() throws IOException {
- int var1;
- if (this.markedChar <= -1) {
- var1 = 0;
- } else {
- int var2 = this.nextChar - this.markedChar;
- if (var2 >= this.readAheadLimit) {
- this.markedChar = -2;
- this.readAheadLimit = 0;
- var1 = 0;
- } else if (this.readAheadLimit <= this.field_1.length) {
- System.arraycopy(this.field_1, this.markedChar, this.field_1, 0, var2);
- this.markedChar = 0;
- var1 = var2;
- } else {
- char[] var3 = new char[this.readAheadLimit];
- System.arraycopy(this.field_1, this.markedChar, var3, 0, var2);
- this.field_1 = var3;
- this.markedChar = 0;
- var1 = var2;
- }
- }
-
- int var4;
- do {
- var4 = this.field_0.read(this.field_1, var1, this.field_1.length - var1);
- } while(var4 == 0);
-
- if (var4 > 0) {
- this.nChars = var1 + var4;
- this.nextChar = var1;
- }
-
- }
-
- public int read() throws IOException {
- Object var2 = super.lock;
- synchronized(var2){}
-
- try {
- this.ensureOpen();
- if (this.nextChar >= this.nChars) {
- this.fill();
- if (this.nextChar >= this.nChars) {
- byte var6 = -1;
- return var6;
- }
- }
-
- char var1 = this.field_1[this.nextChar++];
- return var1;
- } catch (Throwable var5) {
- throw var5;
- }
- }
-
- public int read(char[] var1, int var2, int var3) throws IOException {
- Object var5 = super.lock;
- synchronized(var5){}
-
- int var4;
- try {
- this.ensureOpen();
- if (this.nextChar >= this.nChars) {
- if (var3 >= this.field_1.length && this.markedChar <= -1) {
- var4 = this.field_0.read(var1, var2, var3);
- return var4;
- }
-
- this.fill();
- }
-
- if (this.nextChar < this.nChars) {
- int var7 = Math.min(var3, this.nChars - this.nextChar);
- System.arraycopy(this.field_1, this.nextChar, var1, var2, var7);
- this.nextChar += var7;
- var4 = var7;
- return var4;
- }
-
- var4 = -1;
- } catch (Throwable var9) {
- throw var9;
- }
-
- return var4;
- }
-
- public String readLine() throws IOException {
- StringBuffer var1 = new StringBuffer(defaultExpectedLineLength);
- Object var3 = super.lock;
- synchronized(var3){}
-
- try {
- this.ensureOpen();
-
- boolean var5;
- char var6;
- do {
- if (this.nextChar >= this.nChars) {
- this.fill();
- }
-
- if (this.nextChar >= this.nChars) {
- if (var1.length() <= 0) {
- Object var10 = null;
- return (String)var10;
- }
-
- String var2 = var1.toString();
- return var2;
- }
-
- var5 = false;
- var6 = 0;
-
- int var7;
- for(var7 = this.nextChar; var7 < this.nChars; ++var7) {
- var6 = this.field_1[var7];
- if (var6 == '\n' || var6 == '\r') {
- var5 = true;
- break;
- }
- }
-
- var1.append(this.field_1, this.nextChar, var7 - this.nextChar);
- this.nextChar = var7;
- } while(!var5);
-
- ++this.nextChar;
- if (var6 != '\r') {
- return var1.toString();
- } else {
- if (this.nextChar >= this.nChars) {
- this.fill();
- }
-
- if (this.nextChar < this.nChars && this.field_1[this.nextChar] == '\n') {
- ++this.nextChar;
- }
-
- return var1.toString();
- }
- } catch (Throwable var9) {
- throw var9;
- }
- }
-
- public long skip(long var1) throws IOException {
- Object var5 = super.lock;
- synchronized(var5){}
-
- long var3;
- try {
- this.ensureOpen();
-
- long var7;
- for(var7 = var1; var7 > 0L; this.nextChar = this.nChars) {
- if (this.nextChar >= this.nChars) {
- this.fill();
- }
-
- if (this.nextChar >= this.nChars) {
- break;
- }
-
- long var9 = (long)(this.nChars - this.nextChar);
- if (var7 <= var9) {
- this.nextChar = (int)((long)this.nextChar + var7);
- var7 = 0L;
- break;
- }
-
- var7 -= var9;
- }
-
- var3 = var1 - var7;
- } catch (Throwable var12) {
- throw var12;
- }
-
- return var3;
- }
-
- public boolean ready() throws IOException {
- Object var2 = super.lock;
- synchronized(var2){}
-
- boolean var1;
- try {
- this.ensureOpen();
- var1 = this.nextChar < this.nChars || this.field_0.ready();
- } catch (Throwable var5) {
- throw var5;
- }
-
- return var1;
- }
-
- public boolean markSupported() {
- return true;
- }
-
- public void mark(int var1) throws IOException {
- if (var1 < 0) {
- throw new IllegalArgumentException("Read-ahead limit < 0");
- } else {
- Object var2 = super.lock;
- synchronized(var2){}
-
- try {
- this.ensureOpen();
- this.readAheadLimit = var1;
- this.markedChar = this.nextChar;
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
- }
-
- public void reset() throws IOException {
- Object var1 = super.lock;
- synchronized(var1){}
-
- try {
- this.ensureOpen();
- if (this.markedChar < 0) {
- throw new IOException(this.markedChar == -2 ? "Mark invalid" : "Stream not marked");
- }
-
- this.nextChar = this.markedChar;
- } catch (Throwable var3) {
- throw var3;
- }
-
- }
-
- 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;
- return;
- }
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
- }
-