CountingInputStream.java
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.internal.io;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
public class CountingInputStream
extends FilterInputStream {
private long offset;
public CountingInputStream(InputStream is) {
super(is);
}
@Override
public int read() throws IOException {
int b = super.read();
if (b != -1) {
++this.offset;
}
return b;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int bytesRead = super.read(b, off, len);
if (bytesRead > 0) {
this.offset += (long)bytesRead;
}
return bytesRead;
}
@Override
public int read(byte[] b) throws IOException {
int bytesRead = super.read(b);
if (bytesRead > 0) {
this.offset += (long)bytesRead;
}
return bytesRead;
}
@Override
public long skip(long n) throws IOException {
long bytesSkipped = super.skip(n);
if (bytesSkipped > 0) {
this.offset += bytesSkipped;
}
return bytesSkipped;
}
public long getOffset() {
return this.offset;
}
}