package k0;

import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/* JADX INFO: loaded from: classes.dex */
public abstract class e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private String f4555a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private File f4556b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private FileOutputStream f4557c;

    e(String str) {
        this.f4555a = str;
        this.f4556b = new File(this.f4555a);
    }

    private void a() {
        try {
            File parentFile = this.f4556b.getParentFile();
            if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
                Log.d("TestFile", " mkdirs failed:" + parentFile.getPath());
            }
            if (!this.f4556b.exists()) {
                Log.d("TestFile", this.f4555a + " createFile:" + this.f4556b.createNewFile());
            }
            this.f4557c = new FileOutputStream(this.f4556b);
        } catch (Exception e2) {
            e2.printStackTrace();
            Log.d("TestFile", "Exception e:" + e2);
        }
    }

    public void b() {
        FileOutputStream fileOutputStream = this.f4557c;
        if (fileOutputStream == null) {
            return;
        }
        try {
            fileOutputStream.flush();
            this.f4557c.close();
            this.f4557c = null;
        } catch (IOException e2) {
            e2.printStackTrace();
            Log.d("TestFile", "IOException e:" + e2);
        }
    }

    public void c() {
        a();
    }

    public void d(byte[] bArr, int i2, int i3) {
        FileOutputStream fileOutputStream = this.f4557c;
        if (fileOutputStream == null) {
            return;
        }
        try {
            fileOutputStream.write(bArr, i2, i3);
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }
}
