home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / io / ByteArrayInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.2 KB  |  72 lines

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