alexandroid/decompiled/jadx/sources/com/google/common/io/CountingInputStream.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

69 lines
2.1 KiB
Java

package com.google.common.io;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.base.Preconditions;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@J2ktIncompatible
@GwtIncompatible
/* loaded from: classes8.dex */
public final class CountingInputStream extends FilterInputStream {
private long count;
private long mark;
public CountingInputStream(InputStream inputStream) {
super((InputStream) Preconditions.checkNotNull(inputStream));
this.mark = -1L;
}
public long getCount() {
return this.count;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized void mark(int i) {
((FilterInputStream) this).in.mark(i);
this.mark = this.count;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read() throws IOException {
int read = ((FilterInputStream) this).in.read();
if (read != -1) {
this.count++;
}
return read;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized void reset() throws IOException {
if (!((FilterInputStream) this).in.markSupported()) {
throw new IOException("Mark not supported");
}
if (this.mark == -1) {
throw new IOException("Mark not set");
}
((FilterInputStream) this).in.reset();
this.count = this.mark;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public long skip(long j) throws IOException {
long skip = ((FilterInputStream) this).in.skip(j);
this.count += skip;
return skip;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
int read = ((FilterInputStream) this).in.read(bArr, i, i2);
if (read != -1) {
this.count += read;
}
return read;
}
}