mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-03 19:18:54 +01:00
58 lines
1.8 KiB
Java
58 lines
1.8 KiB
Java
package com.google.common.hash;
|
|
|
|
import com.google.common.annotations.Beta;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
|
import java.io.FilterInputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Beta
|
|
/* loaded from: classes8.dex */
|
|
public final class HashingInputStream extends FilterInputStream {
|
|
private final Hasher hasher;
|
|
|
|
public HashingInputStream(HashFunction hashFunction, InputStream inputStream) {
|
|
super((InputStream) Preconditions.checkNotNull(inputStream));
|
|
this.hasher = (Hasher) Preconditions.checkNotNull(hashFunction.newHasher());
|
|
}
|
|
|
|
public HashCode hash() {
|
|
return this.hasher.hash();
|
|
}
|
|
|
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
|
public boolean markSupported() {
|
|
return false;
|
|
}
|
|
|
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
|
@CanIgnoreReturnValue
|
|
public int read() throws IOException {
|
|
int read = ((FilterInputStream) this).in.read();
|
|
if (read != -1) {
|
|
this.hasher.putByte((byte) read);
|
|
}
|
|
return read;
|
|
}
|
|
|
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
|
public void reset() throws IOException {
|
|
throw new IOException("reset not supported");
|
|
}
|
|
|
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
|
@CanIgnoreReturnValue
|
|
public int read(byte[] bArr, int i, int i2) throws IOException {
|
|
int read = ((FilterInputStream) 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 mark(int i) {
|
|
}
|
|
}
|