home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / prog / VJ11 / VJTRIAL.EXE / IE30Java.exe / classd.exe / java / io / ByteArrayInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-27  |  1.1 KB  |  63 lines

  1. package java.io;
  2.  
  3. public class ByteArrayInputStream extends InputStream {
  4.    protected byte[] buf;
  5.    protected int pos;
  6.    protected int count;
  7.  
  8.    public ByteArrayInputStream(byte[] var1) {
  9.       this.buf = var1;
  10.       this.pos = 0;
  11.       this.count = var1.length;
  12.    }
  13.  
  14.    public ByteArrayInputStream(byte[] var1, int var2, int var3) {
  15.       this.buf = var1;
  16.       this.pos = var2;
  17.       this.count = Math.min(var2 + var3, var1.length);
  18.    }
  19.  
  20.    public synchronized int read() {
  21.       return this.pos < this.count ? this.buf[this.pos++] & 255 : -1;
  22.    }
  23.  
  24.    public synchronized int read(byte[] var1, int var2, int var3) {
  25.       if (this.pos >= this.count) {
  26.          return -1;
  27.       } else {
  28.          if (this.pos + var3 > this.count) {
  29.             var3 = this.count - this.pos;
  30.          }
  31.  
  32.          if (var3 <= 0) {
  33.             return 0;
  34.          } else {
  35.             System.arraycopy(this.buf, this.pos, var1, var2, var3);
  36.             this.pos += var3;
  37.             return var3;
  38.          }
  39.       }
  40.    }
  41.  
  42.    public synchronized long skip(long var1) {
  43.       if ((long)this.pos + var1 > (long)this.count) {
  44.          var1 = (long)(this.count - this.pos);
  45.       }
  46.  
  47.       if (var1 < 0L) {
  48.          return 0L;
  49.       } else {
  50.          this.pos = (int)((long)this.pos + var1);
  51.          return var1;
  52.       }
  53.    }
  54.  
  55.    public synchronized int available() {
  56.       return this.count - this.pos;
  57.    }
  58.  
  59.    public synchronized void reset() {
  60.       this.pos = 0;
  61.    }
  62. }
  63.