what-the-bank/sources/o/C1243Ytq.java

93 lines
2.4 KiB
Java

package o;
import java.io.IOException;
import java.io.OutputStream;
/* renamed from: o.Ytq, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1243Ytq extends OutputStream {
private int b;
private final OutputStream c;
private byte[] d;
private Opg e;
public C1243Ytq(OutputStream outputStream, Opg opg) {
this(outputStream, opg, (byte) 0);
}
private C1243Ytq(OutputStream outputStream, Opg opg, byte b) {
this.c = outputStream;
this.e = opg;
this.d = (byte[]) opg.e(65536, byte[].class);
}
@Override // java.io.OutputStream
public final void write(int i) throws IOException {
byte[] bArr = this.d;
int i2 = this.b;
this.b = i2 + 1;
bArr[i2] = (byte) i;
d();
}
@Override // java.io.OutputStream
public final void write(byte[] bArr) throws IOException {
write(bArr, 0, bArr.length);
}
@Override // java.io.OutputStream
public final void write(byte[] bArr, int i, int i2) throws IOException {
int i3 = 0;
do {
int i4 = i2 - i3;
int i5 = i + i3;
int i6 = this.b;
if (i6 == 0 && i4 >= this.d.length) {
this.c.write(bArr, i5, i4);
return;
}
int min = Math.min(i4, this.d.length - i6);
System.arraycopy(bArr, i5, this.d, this.b, min);
this.b += min;
i3 += min;
d();
} while (i3 < i2);
}
@Override // java.io.OutputStream, java.io.Flushable
public final void flush() throws IOException {
int i = this.b;
if (i > 0) {
this.c.write(this.d, 0, i);
this.b = 0;
}
this.c.flush();
}
private void d() throws IOException {
int i = this.b;
byte[] bArr = this.d;
if (i != bArr.length || i <= 0) {
return;
}
this.c.write(bArr, 0, i);
this.b = 0;
}
@Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
public final void close() throws IOException {
try {
flush();
this.c.close();
byte[] bArr = this.d;
if (bArr != null) {
this.e.b(bArr);
this.d = null;
}
} catch (Throwable th) {
this.c.close();
throw th;
}
}
}