78 lines
2.3 KiB
Java
78 lines
2.3 KiB
Java
|
package c.f.d.j;
|
||
|
|
||
|
import java.io.FilterInputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
/* compiled from: LimitedInputStream */
|
||
|
public class a extends FilterInputStream {
|
||
|
public int i;
|
||
|
public int j;
|
||
|
|
||
|
public a(InputStream inputStream, int i) {
|
||
|
super(inputStream);
|
||
|
if (i >= 0) {
|
||
|
this.i = i;
|
||
|
this.j = -1;
|
||
|
return;
|
||
|
}
|
||
|
throw new IllegalArgumentException("limit must be >= 0");
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public int available() throws IOException {
|
||
|
return Math.min(((FilterInputStream) this).in.available(), this.i);
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public void mark(int i) {
|
||
|
if (((FilterInputStream) this).in.markSupported()) {
|
||
|
((FilterInputStream) this).in.mark(i);
|
||
|
this.j = this.i;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public int read() throws IOException {
|
||
|
if (this.i == 0) {
|
||
|
return -1;
|
||
|
}
|
||
|
int read = ((FilterInputStream) this).in.read();
|
||
|
if (read != -1) {
|
||
|
this.i--;
|
||
|
}
|
||
|
return read;
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public int read(byte[] bArr, int i, int i2) throws IOException {
|
||
|
int i3 = this.i;
|
||
|
if (i3 == 0) {
|
||
|
return -1;
|
||
|
}
|
||
|
int read = ((FilterInputStream) this).in.read(bArr, i, Math.min(i2, i3));
|
||
|
if (read > 0) {
|
||
|
this.i -= read;
|
||
|
}
|
||
|
return read;
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public void reset() throws IOException {
|
||
|
if (!((FilterInputStream) this).in.markSupported()) {
|
||
|
throw new IOException("mark is not supported");
|
||
|
} else if (this.j != -1) {
|
||
|
((FilterInputStream) this).in.reset();
|
||
|
this.i = this.j;
|
||
|
} else {
|
||
|
throw new IOException("mark not set");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public long skip(long j) throws IOException {
|
||
|
long skip = ((FilterInputStream) this).in.skip(Math.min(j, (long) this.i));
|
||
|
this.i = (int) (((long) this.i) - skip);
|
||
|
return skip;
|
||
|
}
|
||
|
}
|