home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / util / jar / Manifest$FastInputStream.class (.txt) < prev   
Encoding:
Java Class File  |  1979-12-31  |  1.6 KB  |  147 lines

  1. package java.util.jar;
  2.  
  3. import java.io.FilterInputStream;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6.  
  7. class Manifest$FastInputStream extends FilterInputStream {
  8.    private byte[] buf;
  9.    private int count;
  10.    private int pos;
  11.  
  12.    Manifest$FastInputStream(InputStream var1) {
  13.       this(var1, 8192);
  14.    }
  15.  
  16.    Manifest$FastInputStream(InputStream var1, int var2) {
  17.       super(var1);
  18.       this.count = 0;
  19.       this.pos = 0;
  20.       this.buf = new byte[var2];
  21.    }
  22.  
  23.    public int read() throws IOException {
  24.       if (this.pos >= this.count) {
  25.          this.fill();
  26.          if (this.pos >= this.count) {
  27.             return -1;
  28.          }
  29.       }
  30.  
  31.       return this.buf[this.pos++] & 255;
  32.    }
  33.  
  34.    public int read(byte[] var1, int var2, int var3) throws IOException {
  35.       int var4 = this.count - this.pos;
  36.       if (var4 <= 0) {
  37.          if (var3 >= this.buf.length) {
  38.             return super.in.read(var1, var2, var3);
  39.          }
  40.  
  41.          this.fill();
  42.          var4 = this.count - this.pos;
  43.          if (var4 <= 0) {
  44.             return -1;
  45.          }
  46.       }
  47.  
  48.       if (var3 > var4) {
  49.          var3 = var4;
  50.       }
  51.  
  52.       System.arraycopy(this.buf, this.pos, var1, var2, var3);
  53.       this.pos += var3;
  54.       return var3;
  55.    }
  56.  
  57.    public int readLine(byte[] var1, int var2, int var3) throws IOException {
  58.       byte[] var4 = this.buf;
  59.       int var5 = 0;
  60.  
  61.       while(var5 < var3) {
  62.          int var6 = this.count - this.pos;
  63.          if (var6 <= 0) {
  64.             this.fill();
  65.             var6 = this.count - this.pos;
  66.             if (var6 <= 0) {
  67.                return -1;
  68.             }
  69.          }
  70.  
  71.          int var7 = var3 - var5;
  72.          if (var7 > var6) {
  73.             var7 = var6;
  74.          }
  75.  
  76.          int var8 = this.pos;
  77.          int var9 = var8 + var7;
  78.  
  79.          while(var8 < var9 && var4[var8++] != 10) {
  80.          }
  81.  
  82.          var7 = var8 - this.pos;
  83.          System.arraycopy(var4, this.pos, var1, var2, var7);
  84.          var2 += var7;
  85.          var5 += var7;
  86.          this.pos = var8;
  87.          if (var4[var8 - 1] == 10) {
  88.             break;
  89.          }
  90.       }
  91.  
  92.       return var5;
  93.    }
  94.  
  95.    public byte peek() throws IOException {
  96.       if (this.pos == this.count) {
  97.          this.fill();
  98.       }
  99.  
  100.       return this.buf[this.pos];
  101.    }
  102.  
  103.    public int readLine(byte[] var1) throws IOException {
  104.       return this.readLine(var1, 0, var1.length);
  105.    }
  106.  
  107.    public long skip(long var1) throws IOException {
  108.       if (var1 <= 0L) {
  109.          return 0L;
  110.       } else {
  111.          long var3 = (long)(this.count - this.pos);
  112.          if (var3 <= 0L) {
  113.             return super.in.skip(var1);
  114.          } else {
  115.             if (var1 > var3) {
  116.                var1 = var3;
  117.             }
  118.  
  119.             this.pos = (int)((long)this.pos + var1);
  120.             return var1;
  121.          }
  122.       }
  123.    }
  124.  
  125.    public int available() throws IOException {
  126.       return this.count - this.pos + super.in.available();
  127.    }
  128.  
  129.    public void close() throws IOException {
  130.       if (super.in != null) {
  131.          super.in.close();
  132.          super.in = null;
  133.          this.buf = null;
  134.       }
  135.  
  136.    }
  137.  
  138.    private void fill() throws IOException {
  139.       this.count = this.pos = 0;
  140.       int var1 = super.in.read(this.buf, 0, this.buf.length);
  141.       if (var1 > 0) {
  142.          this.count = var1;
  143.       }
  144.  
  145.    }
  146. }
  147.