home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- public class PushbackInputStream extends FilterInputStream {
- protected byte[] buf;
- protected int pos;
-
- public PushbackInputStream(InputStream var1, int var2) {
- super(var1);
- this.buf = new byte[var2];
- this.pos = var2;
- }
-
- public PushbackInputStream(InputStream var1) {
- this(var1, 1);
- }
-
- public int read() throws IOException {
- return this.pos < this.buf.length ? this.buf[this.pos++] & 255 : super.read();
- }
-
- public int read(byte[] var1, int var2, int var3) throws IOException {
- if (var3 <= 0) {
- return 0;
- } else {
- int var4 = this.buf.length - this.pos;
- if (var4 > 0) {
- if (var3 < var4) {
- var4 = var3;
- }
-
- System.arraycopy(this.buf, this.pos, var1, var2, var4);
- this.pos += var4;
- var2 += var4;
- var3 -= var4;
- }
-
- if (var3 > 0) {
- var3 = super.read(var1, var2, var3);
- if (var3 == -1) {
- return var4 == 0 ? -1 : var4;
- } else {
- return var4 + var3;
- }
- } else {
- return var4;
- }
- }
- }
-
- public void unread(int var1) throws IOException {
- if (this.pos == 0) {
- throw new IOException("Push back buffer is full");
- } else {
- this.buf[--this.pos] = (byte)var1;
- }
- }
-
- public void unread(byte[] var1, int var2, int var3) throws IOException {
- if (var3 > this.pos) {
- throw new IOException("Push back buffer is full");
- } else {
- this.pos -= var3;
- System.arraycopy(var1, var2, this.buf, this.pos, var3);
- }
- }
-
- public void unread(byte[] var1) throws IOException {
- this.unread(var1, 0, var1.length);
- }
-
- public int available() throws IOException {
- return this.pos + super.available();
- }
-
- public boolean markSupported() {
- return false;
- }
- }
-