package androidx.media3.datasource.cache; import androidx.media3.common.util.Assertions; import androidx.media3.common.util.Util; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.OutputStream; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class ReusableBufferedOutputStream extends BufferedOutputStream { private boolean closed; public ReusableBufferedOutputStream(OutputStream outputStream) { super(outputStream); } public ReusableBufferedOutputStream(OutputStream outputStream, int i) { super(outputStream, i); } @Override // java.io.FilterOutputStream, java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable public void close() throws IOException { this.closed = true; try { flush(); th = null; } catch (Throwable th) { th = th; } try { this.out.close(); } catch (Throwable th2) { if (th == null) { th = th2; } } if (th != null) { Util.sneakyThrow(th); } } public void reset(OutputStream outputStream) { Assertions.checkState(this.closed); this.out = outputStream; this.count = 0; this.closed = false; } }