package org.bouncycastle.util.io; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /* loaded from: classes6.dex */ public class TeeInputStream extends InputStream { private final InputStream input; private final OutputStream output; @Override // java.io.InputStream public int read(byte[] bArr, int i, int i2) throws IOException { int read = this.input.read(bArr, i, i2); if (read > 0) { this.output.write(bArr, i, read); } return read; } @Override // java.io.InputStream public int read(byte[] bArr) throws IOException { return read(bArr, 0, bArr.length); } @Override // java.io.InputStream public int read() throws IOException { int read = this.input.read(); if (read >= 0) { this.output.write(read); } return read; } public OutputStream getOutputStream() { return this.output; } @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable public void close() throws IOException { this.input.close(); this.output.close(); } public TeeInputStream(InputStream inputStream, OutputStream outputStream) { this.input = inputStream; this.output = outputStream; } }