home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- public class BufferedInputStream extends FilterInputStream {
- protected byte[] buf;
- protected int count;
- protected int pos;
- protected int markpos;
- protected int marklimit;
-
- public BufferedInputStream(InputStream var1) {
- this(var1, 2048);
- }
-
- public BufferedInputStream(InputStream var1, int var2) {
- super(var1);
- this.markpos = -1;
- this.buf = new byte[var2];
- }
-
- private void fill() throws IOException {
- if (this.markpos < 0) {
- this.pos = 0;
- } else if (this.pos >= this.buf.length) {
- if (this.markpos > 0) {
- int var1 = this.pos - this.markpos;
- System.arraycopy(this.buf, this.markpos, this.buf, 0, var1);
- this.pos = var1;
- this.markpos = 0;
- } else if (this.buf.length >= this.marklimit) {
- this.markpos = -1;
- this.pos = 0;
- } else {
- int var3 = this.pos * 2;
- if (var3 > this.marklimit) {
- var3 = this.marklimit;
- }
-
- byte[] var2 = new byte[var3];
- System.arraycopy(this.buf, 0, var2, 0, this.pos);
- this.buf = var2;
- }
- }
-
- int var4 = super.in.read(this.buf, this.pos, this.buf.length - this.pos);
- this.count = var4 <= 0 ? this.pos : var4 + this.pos;
- }
-
- public synchronized int read() throws IOException {
- if (this.pos >= this.count) {
- this.fill();
- if (this.pos >= this.count) {
- return -1;
- }
- }
-
- return this.buf[this.pos++] & 255;
- }
-
- public synchronized int read(byte[] var1, int var2, int var3) throws IOException {
- int var4 = this.count - this.pos;
- if (var4 <= 0) {
- if (var3 >= this.buf.length && this.markpos < 0) {
- return super.in.read(var1, var2, var3);
- }
-
- this.fill();
- var4 = this.count - this.pos;
- if (var4 <= 0) {
- return -1;
- }
- }
-
- int var5 = var4 < var3 ? var4 : var3;
- System.arraycopy(this.buf, this.pos, var1, var2, var5);
- this.pos += var5;
- return var5;
- }
-
- public synchronized long skip(long var1) throws IOException {
- if (var1 < 0L) {
- return 0L;
- } else {
- long var3 = (long)(this.count - this.pos);
- if (var3 >= var1) {
- this.pos = (int)((long)this.pos + var1);
- return var1;
- } else {
- this.pos = (int)((long)this.pos + var3);
- return var3 + super.in.skip(var1 - var3);
- }
- }
- }
-
- public synchronized int available() throws IOException {
- return this.count - this.pos + super.in.available();
- }
-
- public synchronized void mark(int var1) {
- this.marklimit = var1;
- this.markpos = this.pos;
- }
-
- public synchronized void reset() throws IOException {
- if (this.markpos < 0) {
- throw new IOException("Resetting to invalid mark");
- } else {
- this.pos = this.markpos;
- }
- }
-
- public boolean markSupported() {
- return true;
- }
- }
-