Rabbit-R1/android (non root)/java/sources/com/google/common/hash/HashingOutputStream.java

39 lines
1.2 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package com.google.common.hash;
import com.google.common.base.Preconditions;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.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 void write(int i) throws IOException {
this.hasher.putByte((byte) i);
this.out.write(i);
}
@Override // java.io.FilterOutputStream, java.io.OutputStream
public void write(byte[] bArr, int i, int i2) throws IOException {
this.hasher.putBytes(bArr, i, i2);
this.out.write(bArr, i, i2);
}
public HashCode hash() {
return this.hasher.hash();
}
@Override // java.io.FilterOutputStream, java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.out.close();
}
}