what-the-bank/sources/com/google/common/hash/HashingOutputStream.java

38 lines
1.3 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.hash;
import com.google.common.base.Preconditions;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/* loaded from: classes2.dex */
public final class HashingOutputStream extends FilterOutputStream {
private final Hasher hasher;
public HashingOutputStream(HashFunction hashFunction, OutputStream outputStream) {
super((OutputStream) Preconditions.checkNotNull(outputStream));
this.hasher = (Hasher) Preconditions.checkNotNull(hashFunction.newHasher());
}
@Override // java.io.FilterOutputStream, java.io.OutputStream
public final void write(int i) throws IOException {
this.hasher.putByte((byte) i);
((FilterOutputStream) this).out.write(i);
}
@Override // java.io.FilterOutputStream, java.io.OutputStream
public final void write(byte[] bArr, int i, int i2) throws IOException {
this.hasher.putBytes(bArr, i, i2);
((FilterOutputStream) this).out.write(bArr, i, i2);
}
public final HashCode hash() {
return this.hasher.hash();
}
@Override // java.io.FilterOutputStream, java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
public final void close() throws IOException {
((FilterOutputStream) this).out.close();
}
}