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 / StringBufferInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  876 b   |  70 lines

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