package i;

import d.C0424d;
import java.io.IOException;
import java.io.Reader;
import java.lang.reflect.Type;
import java.sql.Clob;
import java.sql.SQLException;

/* JADX INFO: renamed from: i.s, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C0538s implements U {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final C0538s f4379a = new C0538s();

    @Override // i.U
    public void a(C0516I c0516i, Object obj, Object obj2, Type type, int i2) throws IOException {
        try {
            if (obj == null) {
                c0516i.x();
                return;
            }
            Reader characterStream = ((Clob) obj).getCharacterStream();
            StringBuilder sb = new StringBuilder();
            try {
                char[] cArr = new char[2048];
                while (true) {
                    int i3 = characterStream.read(cArr, 0, 2048);
                    if (i3 < 0) {
                        String string = sb.toString();
                        characterStream.close();
                        c0516i.w(string);
                        return;
                    }
                    sb.append(cArr, 0, i3);
                }
            } catch (Exception e2) {
                throw new C0424d("read string from reader error", e2);
            }
        } catch (SQLException e3) {
            throw new IOException("write clob error", e3);
        }
    }
}
