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 / io / ByteArrayInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  1.3 KB  |  93 lines

  1. package java.io;
  2.  
  3. public class ByteArrayInputStream extends InputStream {
  4.    private boolean isClosed = false;
  5.    protected byte[] buf;
  6.    protected int pos;
  7.    protected int mark = 0;
  8.    protected int count;
  9.  
  10.    public ByteArrayInputStream(byte[] var1) {
  11.       this.buf = var1;
  12.       this.pos = 0;
  13.       this.count = var1.length;
  14.    }
  15.  
  16.    public ByteArrayInputStream(byte[] var1, int var2, int var3) {
  17.       this.buf = var1;
  18.       this.pos = var2;
  19.       this.count = Math.min(var2 + var3, var1.length);
  20.       this.mark = var2;
  21.    }
  22.  
  23.    public synchronized int read() {
  24.       this.ensureOpen();
  25.       return this.pos < this.count ? this.buf[this.pos++] & 255 : -1;
  26.    }
  27.  
  28.    public synchronized int read(byte[] var1, int var2, int var3) {
  29.       this.ensureOpen();
  30.       if (var1 == null) {
  31.          throw new NullPointerException();
  32.       } else if (var2 >= 0 && var2 <= var1.length && var3 >= 0 && var2 + var3 <= var1.length && var2 + var3 >= 0) {
  33.          if (this.pos >= this.count) {
  34.             return -1;
  35.          } else {
  36.             if (this.pos + var3 > this.count) {
  37.                var3 = this.count - this.pos;
  38.             }
  39.  
  40.             if (var3 <= 0) {
  41.                return 0;
  42.             } else {
  43.                System.arraycopy(this.buf, this.pos, var1, var2, var3);
  44.                this.pos += var3;
  45.                return var3;
  46.             }
  47.          }
  48.       } else {
  49.          throw new IndexOutOfBoundsException();
  50.       }
  51.    }
  52.  
  53.    public synchronized long skip(long var1) {
  54.       this.ensureOpen();
  55.       if ((long)this.pos + var1 > (long)this.count) {
  56.          var1 = (long)(this.count - this.pos);
  57.       }
  58.  
  59.       if (var1 < 0L) {
  60.          return 0L;
  61.       } else {
  62.          this.pos = (int)((long)this.pos + var1);
  63.          return var1;
  64.       }
  65.    }
  66.  
  67.    public synchronized int available() {
  68.       this.ensureOpen();
  69.       return this.count - this.pos;
  70.    }
  71.  
  72.    public boolean markSupported() {
  73.       return true;
  74.    }
  75.  
  76.    public void mark(int var1) {
  77.       this.ensureOpen();
  78.       this.mark = this.pos;
  79.    }
  80.  
  81.    public synchronized void reset() {
  82.       this.ensureOpen();
  83.       this.pos = this.mark;
  84.    }
  85.  
  86.    public synchronized void close() throws IOException {
  87.       this.isClosed = true;
  88.    }
  89.  
  90.    private void ensureOpen() {
  91.    }
  92. }
  93.