package com.helpshift.util; import com.helpshift.log.HSLogger; import java.io.File; import java.io.FileInputStream; /* loaded from: classes3.dex */ public abstract class FileUtil { public static String readFileToString(String str) { FileInputStream fileInputStream; Exception e; FileInputStream fileInputStream2 = null; try { File file = new File(str); fileInputStream = new FileInputStream(file); try { try { int length = (int) file.length(); byte[] bArr = new byte[length]; fileInputStream.read(bArr, 0, length); String str2 = new String(bArr); Utils.closeQuietly(fileInputStream); return str2; } catch (Exception e2) { e = e2; HSLogger.e("fileutil", "Error reading file: " + str, e); Utils.closeQuietly(fileInputStream); return ""; } } catch (Throwable th) { th = th; fileInputStream2 = fileInputStream; Utils.closeQuietly(fileInputStream2); throw th; } } catch (Exception e3) { fileInputStream = null; e = e3; } catch (Throwable th2) { th = th2; Utils.closeQuietly(fileInputStream2); throw th; } } public static void deleteDir(String str) { File file = new File(str); if (file.exists()) { File[] listFiles = file.listFiles(); if (listFiles == null || listFiles.length == 0) { file.delete(); return; } for (File file2 : listFiles) { if (file2.isDirectory()) { deleteDir(file2.getAbsolutePath()); } file2.delete(); } file.delete(); } } }