Rabbit-R1/switch port/java/sources/com/google/common/hash/HashingInputStream.java
2024-05-21 17:08:36 -04:00

53 lines
1.6 KiB
Java

package com.google.common.hash;
import com.google.common.base.Preconditions;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
public final class HashingInputStream extends FilterInputStream {
private final Hasher hasher;
@Override // java.io.FilterInputStream, java.io.InputStream
public void mark(int i) {
}
@Override // java.io.FilterInputStream, java.io.InputStream
public boolean markSupported() {
return false;
}
public HashingInputStream(HashFunction hashFunction, InputStream inputStream) {
super((InputStream) Preconditions.checkNotNull(inputStream));
this.hasher = (Hasher) Preconditions.checkNotNull(hashFunction.newHasher());
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read() throws IOException {
int read = this.in.read();
if (read != -1) {
this.hasher.putByte((byte) read);
}
return read;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
int read = this.in.read(bArr, i, i2);
if (read != -1) {
this.hasher.putBytes(bArr, i, read);
}
return read;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public void reset() throws IOException {
throw new IOException("reset not supported");
}
public HashCode hash() {
return this.hasher.hash();
}
}