package n9; import java.io.Closeable; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; /* loaded from: classes2.dex */ public abstract class h0 implements Closeable { class a extends h0 { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ a0 f12387a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ long f12388b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ x9.e f12389c; a(a0 a0Var, long j10, x9.e eVar) { this.f12387a = a0Var; this.f12388b = j10; this.f12389c = eVar; } @Override // n9.h0 public long G() { return this.f12388b; } @Override // n9.h0 public a0 I() { return this.f12387a; } @Override // n9.h0 public x9.e S() { return this.f12389c; } } public static h0 O(a0 a0Var, long j10, x9.e eVar) { if (eVar != null) { return new a(a0Var, j10, eVar); } throw new NullPointerException("source == null"); } public static h0 P(a0 a0Var, String str) { Charset charset = StandardCharsets.UTF_8; if (a0Var != null && (charset = a0Var.a()) == null) { charset = StandardCharsets.UTF_8; a0Var = a0.d(a0Var + "; charset=utf-8"); } x9.c O0 = new x9.c().O0(str, charset); return O(a0Var, O0.u0(), O0); } public static h0 R(a0 a0Var, byte[] bArr) { return O(a0Var, bArr.length, new x9.c().q(bArr)); } private static /* synthetic */ void c(Throwable th, AutoCloseable autoCloseable) { if (th == null) { autoCloseable.close(); return; } try { autoCloseable.close(); } catch (Throwable th2) { th.addSuppressed(th2); } } private Charset z() { a0 I = I(); return I != null ? I.b(StandardCharsets.UTF_8) : StandardCharsets.UTF_8; } public abstract long G(); public abstract a0 I(); public abstract x9.e S(); public final String Y() { x9.e S = S(); try { String k10 = S.k(o9.e.c(S, z())); c(null, S); return k10; } catch (Throwable th) { try { throw th; } catch (Throwable th2) { if (S != null) { c(th, S); } throw th2; } } } @Override // java.io.Closeable, java.lang.AutoCloseable public void close() { o9.e.g(S()); } }