导航菜单

页面标题

页面副标题

Clean Center v0.5.5 - FileUtils.java 源代码

正在查看: Clean Center v0.5.5 应用的 FileUtils.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.trustlook.sdk.ngsescan;

import android.content.Context;
import android.content.res.AssetManager;
import android.os.Environment;
import android.util.Log;
import com.wxiwei.office.fc.openxml4j.opc.PackagingURIHelper;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import trustlook_cloudscan.a;
import trustlook_cloudscan.b;
import trustlook_cloudscan.c;

public class FileUtils {
    private static void a(Context context, String str, String str2) {
        try {
            InputStream open = context.getAssets().open(str2);
            FileOutputStream fileOutputStream = new FileOutputStream(str + PackagingURIHelper.FORWARD_SLASH_STRING + str2);
            byte[] bArr = new byte[1024];
            while (true) {
                int read = open.read(bArr);
                if (read == -1) {
                    open.close();
                    fileOutputStream.flush();
                    fileOutputStream.close();
                    return;
                }
                fileOutputStream.write(bArr, 0, read);
            }
        } catch (Exception e) {
            Log.e("tag", e.getMessage());
        }
    }

    public static String buildFullPath(String str, String str2) {
        if (!str.endsWith(PackagingURIHelper.FORWARD_SLASH_STRING)) {
            str = str + PackagingURIHelper.FORWARD_SLASH_STRING;
        }
        return str + str2;
    }

    public static void copyAsset(Context context) {
        String path = context.getFilesDir().getPath();
        if (!a(buildFullPath(path, "dexdump4"))) {
            copyFileOrDir(context, path, "dexdump4");
            setFileExecutable(context, path, "dexdump4");
        }
        if (!a(buildFullPath(path, "dexdump5"))) {
            copyFileOrDir(context, path, "dexdump5");
            setFileExecutable(context, path, "dexdump5");
        }
        if (!a(buildFullPath(path, "dexdump6"))) {
            copyFileOrDir(context, path, "dexdump6");
            setFileExecutable(context, path, "dexdump6");
        }
        if (a(buildFullPath(path, "dexdump7"))) {
            return;
        }
        copyFileOrDir(context, path, "dexdump7");
        setFileExecutable(context, path, "dexdump7");
    }

    public static String copyAssetAndWrite(Context context, File file, String str) {
        try {
            file.getAbsolutePath();
            File createFile = createFile(file);
            if (createFile == null) {
                return null;
            }
            InputStream open = context.getResources().getAssets().open(str);
            FileOutputStream fileOutputStream = new FileOutputStream(createFile);
            byte[] bArr = new byte[1024];
            while (true) {
                int read = open.read(bArr);
                if (read == -1) {
                    fileOutputStream.flush();
                    open.close();
                    fileOutputStream.close();
                    createFile.getAbsolutePath();
                    long length = createFile.length() / 1024;
                    return createFile.getAbsolutePath();
                }
                fileOutputStream.write(bArr, 0, read);
            }
        } catch (Exception e) {
            a.a(e, c.a("copyAssetAndWrite Exception: "), "TL");
            return null;
        }
    }

    public static void copyFileOrDir(Context context, String str, String str2) {
        try {
            String[] list = context.getAssets().list(str2);
            if (list.length == 0) {
                a(context, str, str2);
                return;
            }
            File file = new File(str + PackagingURIHelper.FORWARD_SLASH_STRING + str2);
            file.setExecutable(true);
            if (!file.exists()) {
                file.mkdir();
            }
            for (String str3 : list) {
                copyFileOrDir(context, str, str2 + PackagingURIHelper.FORWARD_SLASH_STRING + str3);
            }
        } catch (IOException e) {
            Log.e("tag", "I/O Exception", e);
        }
    }

    public static File createFile(File file) {
        File parentFile = file.getParentFile();
        if (!parentFile.exists()) {
            parentFile.mkdirs();
        }
        if (file.exists()) {
            file.delete();
            file.toString();
        }
        boolean z = false;
        try {
            file.exists();
            z = file.createNewFile();
            file.getAbsolutePath();
        } catch (IOException e) {
            b.a(e, c.a("createFile IOException: "), "TL");
        }
        if (z) {
            return file;
        }
        return null;
    }

    public static String formatDecimal(double d, int i) {
        return new BigDecimal(d).setScale(i, 5).toString();
    }

    public static String getJson(Context context, String str) {
        StringBuilder sb = new StringBuilder();
        AssetManager assets = context.getAssets();
        try {
            for (String str2 : assets.list("")) {
            }
        } catch (Exception e) {
            a.a(e, c.a("getJson listAsset exception: "), "TL");
        }
        try {
            InputStream open = assets.open(str);
            open.toString();
            InputStreamReader inputStreamReader = new InputStreamReader(open, "utf-8");
            inputStreamReader.toString();
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            bufferedReader.toString();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine == null) {
                    bufferedReader.close();
                    return sb.toString();
                }
                sb.append(readLine);
            }
        } catch (IOException e2) {
            e2.printStackTrace();
            Log.e("TL", "getJson IOException: " + e2.getMessage());
            return getVirusDescJsonStr();
        }
    }

    public static String getVirusDescJsonStr() {
        return "{\n  \"ver\": 1,\n  \"desc\": {\n    \"0\": {\n      \"name\": \"Android.Benign\",\n      \"desc\": {\n        \"zh\": \"良性\",\n        \"en\": \"Benign app\"\n      },\n      \"cat\": {\n        \"zh\": \"正常\",\n        \"en\": \"Benign\"\n      },\n      \"score\": 0\n    },\n    \"800\": {\n      \"name\": \"Android.Malware.General\",\n      \"desc\": {\n        \"zh\": \"应用可能包含恶意代码, 例如文件或系统损坏或开启后门\",\n        \"en\": \"This app could cause multiple issues like files and system damages or creates backdoor\"\n      },\n      \"cat\": {\n        \"zh\": \"流氓行为\",\n        \"en\": \"Rogue\"\n      },\n      \"score\": 8\n    },\n    \"801\": {\n      \"name\": \"Android.Malware.Trojan\",\n      \"desc\": {\n        \"zh\": \"应用为木马, 控制者可能通过远程C2C服务器发送指令远程控制系统\",\n        \"en\": \"This app could control your device through a C2C server\"\n      },\n      \"cat\": {\n        \"zh\": \"远程控制\",\n        \"en\": \"Remote\"\n      },\n      \"score\": 8\n    },\n    \"802\": {\n      \"name\": \"Android.Malware.Worm\",\n      \"desc\": {\n        \"zh\": \"应用为蠕虫, 可能会造成系统损害并尝试散播到其他装置\",\n        \"en\": \"This app damages system and tries to replicate itself to other devices\"\n      },\n      \"cat\": {\n        \"zh\": \"恶意传播\",\n        \"en\": \"Spread\"\n      },\n      \"score\": 8\n    },\n    \"803\": {\n      \"name\": \"Android.Malware.Ransomware\",\n      \"desc\": {\n        \"zh\": \"应用为勒索软件,加密文件系统或锁屏阻止用户使用直到用户付款\",\n        \"en\": \"This app encrypt the file system or block the user using the system until the ransom is paid\"\n      },\n      \"cat\": {\n        \"zh\": \"诱骗欺诈\",\n        \"en\": \"Fraud\"\n      },\n      \"score\": 8\n    },\n    \"804\": {\n      \"name\": \"Android.Malware.Backdoor\",\n      \"desc\": {\n        \"zh\": \"应用包含后门使用户系统被远程控制,执行系统命令\",\n        \"en\": \"This app contains backdoor that let your device being controlled remotely\"\n      },\n      \"cat\": {\n        \"zh\": \"远程控制\",\n        \"en\": \"Remote\"\n      },\n      \"score\": 8\n    },\n    \"805\": {\n      \"name\": \"Android.Malware.Spyware\",\n      \"desc\": {\n        \"zh\": \"应用可能在后台窃取用户私密信息\",\n        \"en\": \"This app may steal user personal information\"\n      },\n      \"cat\": {\n        \"zh\": \"隐私窃取\",\n        \"en\": \"Privacy\"\n      },\n      \"score\": 8\n    },\n    \"600\": {\n      \"name\": \"Android.PUA.General\",\n      \"desc\": {\n        \"zh\": \"应用可能包含收集用户信息, 扰人广告或引诱付费等行为\",\n        \"en\": \"This app may contain various unwanted behaviors\"\n      },\n      \"cat\": {\n        \"zh\": \"流氓行为\",\n        \"en\": \"Rogue\"\n      },\n      \"score\": 6\n    },\n    \"601\": {\n      \"name\": \"Android.PUA.Riskware\",\n      \"desc\": {\n        \"zh\": \"应用提供的功能可能会对用户造成非预期的影响\",\n        \"en\": \"The features of the app may have potential risks\"\n      },\n      \"cat\": {\n        \"zh\": \"流氓行为\",\n        \"en\": \"Rogue\"\n      },\n      \"score\": 6\n    },\n    \"602\": {\n      \"name\": \"Android.PUA.Tool\",\n      \"desc\": {\n        \"zh\": \"应用为root工具, 可能root系统并取得最高权限\",\n        \"en\": \"This is app will root your system and get root permission\"\n      },\n      \"cat\": {\n        \"zh\": \"系统破坏\",\n        \"en\": \"System\"\n      },\n      \"score\": 6\n    },\n    \"603\": {\n      \"name\": \"Android.PUA.Spyware\",\n      \"desc\": {\n        \"zh\": \"应用可能在后台收集用户信息\",\n        \"en\": \"This app may collect user information\"\n      },\n      \"cat\": {\n        \"zh\": \"隐私窃取\",\n        \"en\": \"Privacy\"\n      },\n      \"score\": 6\n    },\n    \"604\": {\n      \"name\": \"Android.PUA.Hacktool\",\n      \"desc\": {\n        \"zh\": \"应用为黑客工具, 黑客可能透过此应用发起攻击\",\n        \"en\": \"This app is a hacktool that allows the hacker to attack your system\"\n      },\n      \"cat\": {\n        \"zh\": \"系统破坏\",\n        \"en\": \"System\"\n      },\n      \"score\": 6\n    },\n    \"605\": {\n      \"name\": \"Android.PUA.Payware\",\n      \"desc\": {\n        \"zh\": \"应用可能未经受权的情况下向用户收费\",\n        \"en\": \"This app may charge user without consent\"\n      },\n      \"cat\": {\n        \"zh\": \"恶意扣费\",\n        \"en\": \"Payment\"\n      },\n      \"score\": 6\n    },\n    \"606\": {\n      \"name\": \"Android.PUA.Adware\",\n      \"desc\": {\n        \"zh\": \"该应用会在未经受权的情况下恶意推送大量广告而影响正常功能体验\",\n        \"en\": \"This app shows irritating ad frequently\"\n      },\n      \"cat\": {\n        \"zh\": \"资费消耗\",\n        \"en\": \"Expense\"\n      },\n      \"score\": 6\n    },\n    \"-1\": {\n      \"name\": \"Unknown\",\n      \"desc\": {\n        \"zh\": \"暂无描述\",\n        \"en\": \"No description for this family\"\n      },\n      \"cat\": {\n        \"zh\": \"暂无描述\",\n        \"en\": \"Unknown\"\n      },\n      \"score\": 0\n    }\n  }\n}";
    }

    public static List<String> runCommand(String str) {
        ArrayList arrayList = new ArrayList();
        try {
            Process exec = Runtime.getRuntime().exec(str);
            InputStream errorStream = exec.getErrorStream();
            InputStream inputStream = exec.getInputStream();
            OutputStream outputStream = exec.getOutputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(errorStream));
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
            BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(inputStream));
            while (true) {
                String readLine = bufferedReader2.readLine();
                if (readLine == null) {
                    break;
                }
                arrayList.add(readLine + " ");
            }
            bufferedReader2.close();
            exec.waitFor();
            bufferedWriter.close();
            bufferedReader.close();
            errorStream.close();
            inputStream.close();
            outputStream.close();
        } catch (IOException e) {
            b.a(e, c.a("runCommand IOException: "), "TL");
        } catch (InterruptedException e2) {
            Log.e("TL", c.a("runCommand InterruptedException: ").append(e2.getMessage()).toString());
        }
        return (!str.contains("ps") || arrayList.size() <= 0) ? arrayList : arrayList.subList(1, arrayList.size());
    }

    public static String saveDataToFile(String str, String str2, String str3) {
        FileOutputStream fileOutputStream;
        File file = new File(str);
        if (!file.exists() || !file.isDirectory()) {
            file.mkdirs();
        }
        File file2 = new File(file, str2);
        ?? e = 0;
        e = 0;
        e = 0;
        try {
            try {
                try {
                    fileOutputStream = new FileOutputStream(file2);
                } catch (IOException e2) {
                    e = e2;
                    b.a((IOException) e, c.a("saveDataToFile IOException: "), "TL");
                }
                try {
                    byte[] bytes = str3.getBytes();
                    fileOutputStream.write(bytes);
                    fileOutputStream.close();
                    e = bytes;
                } catch (FileNotFoundException e3) {
                    e = e3;
                    e = fileOutputStream;
                    Log.e("TL", "saveDataToFile FileNotFoundException: " + e.getMessage());
                    if (e != 0) {
                        e.close();
                        e = e;
                    }
                    return file2.getAbsolutePath();
                } catch (IOException e4) {
                    e = e4;
                    e = fileOutputStream;
                    Log.e("TL", "saveDataToFile IOException: " + e.getMessage());
                    if (e != 0) {
                        e.close();
                        e = e;
                    }
                    return file2.getAbsolutePath();
                } catch (Throwable th) {
                    th = th;
                    if (fileOutputStream != null) {
                        try {
                            fileOutputStream.close();
                        } catch (IOException e5) {
                            b.a(e5, c.a("saveDataToFile IOException: "), "TL");
                        }
                    }
                    throw th;
                }
            } catch (FileNotFoundException e6) {
                e = e6;
            } catch (IOException e7) {
                e = e7;
            }
            return file2.getAbsolutePath();
        } catch (Throwable th2) {
            th = th2;
            fileOutputStream = e;
        }
    }

    public static void setFileExecutable(Context context, String str, String str2) {
        new File(buildFullPath(str, str2)).setExecutable(true);
    }

    public static void writeDumpOpcodeTime(android.content.Context r8, java.lang.String r9, java.lang.String r10, java.lang.String r11) {
        throw new UnsupportedOperationException("Method not decompiled: com.trustlook.sdk.ngsescan.FileUtils.writeDumpOpcodeTime(android.content.Context, java.lang.String, java.lang.String, java.lang.String):void");
    }

    public static String writeFile(File file, InputStream inputStream) {
        try {
            File createFile = createFile(file);
            if (createFile == null) {
                return null;
            }
            FileOutputStream fileOutputStream = new FileOutputStream(createFile);
            byte[] bArr = new byte[1024];
            while (true) {
                int read = inputStream.read(bArr);
                if (read == -1) {
                    fileOutputStream.flush();
                    inputStream.close();
                    fileOutputStream.close();
                    file.getAbsolutePath();
                    long length = file.length() / 1024;
                    return createFile.getAbsolutePath();
                }
                fileOutputStream.write(bArr, 0, read);
            }
        } catch (Exception e) {
            a.a(e, c.a("writeFile Exception: "), "TL");
            return null;
        }
    }

    public static void writeOpcodeMc(Context context, String str, String str2, String str3) {
        Throwable th;
        ?? r4;
        BufferedWriter bufferedWriter;
        FileWriter fileWriter;
        String buildFullPath = buildFullPath(Environment.getExternalStorageDirectory().getPath(), "opcodemc");
        File file = new File(buildFullPath);
        if (!file.exists() || !file.isDirectory()) {
            file.mkdirs();
        }
        String str4 = context.getPackageManager().getPackageArchiveInfo(str3, 0).packageName;
        String buildFullPath2 = buildFullPath(buildFullPath, str4 + ".opcode");
        String str5 = ".mc";
        String buildFullPath3 = buildFullPath(buildFullPath, str4 + ".mc");
        File file2 = new File(buildFullPath2);
        File file3 = new File(buildFullPath3);
        ?? r7 = null;
        FileWriter fileWriter2 = null;
        FileWriter fileWriter3 = null;
        FileWriter fileWriter4 = null;
        try {
        } catch (Throwable th2) {
            th = th2;
            r7 = str5;
        }
        try {
            try {
                r4 = new FileOutputStream(file2);
            } catch (IOException e) {
                b.a(e, c.a("writeOpcodeMc IOException: "), "TL");
                str5 = str5;
            }
            try {
                r4.write(str.getBytes());
                r4.flush();
                r4.close();
                str5 = r4;
            } catch (FileNotFoundException e2) {
                e = e2;
                Log.e("TL", "writeOpcodeMc FileNotFoundException: " + e.getMessage());
                str5 = r4;
                if (r4 != 0) {
                    r4.close();
                    str5 = r4;
                }
                try {
                    fileWriter = new FileWriter(file3);
                    bufferedWriter = new BufferedWriter(fileWriter);
                } catch (IOException e3) {
                    b.a(e3, c.a("writeOpcodeMc IOException: "), "TL");
                }
                try {
                    bufferedWriter.write(str2);
                    bufferedWriter.flush();
                    try {
                        fileWriter.close();
                    } catch (IOException e4) {
                        e4.printStackTrace();
                    }
                    bufferedWriter.close();
                } catch (FileNotFoundException unused) {
                    fileWriter2 = fileWriter;
                    if (fileWriter2 != null) {
                        try {
                            fileWriter2.close();
                        } catch (IOException e5) {
                            e5.printStackTrace();
                        }
                    }
                    if (bufferedWriter != null) {
                        bufferedWriter.close();
                    }
                    return;
                } catch (IOException unused2) {
                    fileWriter3 = fileWriter;
                    if (fileWriter3 != null) {
                        try {
                            fileWriter3.close();
                        } catch (IOException e6) {
                            e6.printStackTrace();
                        }
                    }
                    if (bufferedWriter != null) {
                        bufferedWriter.close();
                    }
                    return;
                } catch (Throwable th3) {
                    th = th3;
                    fileWriter4 = fileWriter;
                    if (fileWriter4 != null) {
                        try {
                            fileWriter4.close();
                        } catch (IOException e7) {
                            e7.printStackTrace();
                        }
                    }
                    if (bufferedWriter == null) {
                        throw th;
                    }
                    try {
                        bufferedWriter.close();
                        throw th;
                    } catch (IOException e8) {
                        b.a(e8, c.a("writeOpcodeMc IOException: "), "TL");
                        throw th;
                    }
                }
            } catch (IOException e9) {
                e = e9;
                Log.e("TL", "writeOpcodeMc IOException: " + e.getMessage());
                str5 = r4;
                if (r4 != 0) {
                    r4.close();
                    str5 = r4;
                }
                fileWriter = new FileWriter(file3);
                bufferedWriter = new BufferedWriter(fileWriter);
                bufferedWriter.write(str2);
                bufferedWriter.flush();
                fileWriter.close();
                bufferedWriter.close();
            }
        } catch (FileNotFoundException e10) {
            e = e10;
            r4 = 0;
        } catch (IOException e11) {
            e = e11;
            r4 = 0;
        } catch (Throwable th4) {
            th = th4;
            if (r7 != null) {
                try {
                    r7.close();
                } catch (IOException e12) {
                    b.a(e12, c.a("writeOpcodeMc IOException: "), "TL");
                }
            }
            throw th;
        }
        try {
            fileWriter = new FileWriter(file3);
            try {
                bufferedWriter = new BufferedWriter(fileWriter);
                bufferedWriter.write(str2);
                bufferedWriter.flush();
                fileWriter.close();
                bufferedWriter.close();
            } catch (FileNotFoundException unused3) {
                bufferedWriter = null;
            } catch (IOException unused4) {
                bufferedWriter = null;
            } catch (Throwable th5) {
                bufferedWriter = null;
                fileWriter4 = fileWriter;
                th = th5;
            }
        } catch (FileNotFoundException unused5) {
            bufferedWriter = null;
        } catch (IOException unused6) {
            bufferedWriter = null;
        } catch (Throwable th6) {
            th = th6;
            bufferedWriter = null;
        }
    }

    public static void writeRequestData(Context context, String str, String str2) {
        String str3;
        FileOutputStream fileOutputStream;
        try {
            String buildFullPath = buildFullPath(Environment.getExternalStorageDirectory().getPath(), "opcodemc");
            File file = new File(buildFullPath);
            if (!file.exists() || !file.isDirectory()) {
                file.mkdirs();
            }
            File file2 = new File(buildFullPath(buildFullPath, context.getPackageManager().getPackageArchiveInfo(str2, 0).packageName + ".request"));
            FileOutputStream fileOutputStream2 = null;
            try {
                try {
                    fileOutputStream = new FileOutputStream(file2);
                } catch (Throwable th) {
                    th = th;
                    fileOutputStream2 = fileOutputStream2;
                }
            } catch (FileNotFoundException e) {
                e = e;
            } catch (IOException e2) {
                e = e2;
            } catch (Throwable th2) {
                th = th2;
            }
            try {
                fileOutputStream.write(str.toString().getBytes());
                try {
                    fileOutputStream.close();
                } catch (IOException e3) {
                    str3 = "writeRequestData IOException: " + e3.getMessage();
                    Log.e("TL", str3);
                }
            } catch (FileNotFoundException e4) {
                e = e4;
                fileOutputStream2 = fileOutputStream;
                Log.e("TL", "writeRequestData FileNotFoundException: " + e.getMessage());
                if (fileOutputStream2 != null) {
                    try {
                        fileOutputStream2.close();
                    } catch (IOException e5) {
                        str3 = "writeRequestData IOException: " + e5.getMessage();
                        Log.e("TL", str3);
                    }
                }
            } catch (IOException e6) {
                e = e6;
                fileOutputStream2 = fileOutputStream;
                Log.e("TL", "writeRequestData IOException: " + e.getMessage());
                if (fileOutputStream2 != null) {
                    try {
                        fileOutputStream2.close();
                    } catch (IOException e7) {
                        str3 = "writeRequestData IOException: " + e7.getMessage();
                        Log.e("TL", str3);
                    }
                }
            } catch (Throwable th3) {
                th = th3;
                fileOutputStream2 = fileOutputStream;
                if (fileOutputStream2 != null) {
                    try {
                        fileOutputStream2.close();
                    } catch (IOException e8) {
                        Log.e("TL", "writeRequestData IOException: " + e8.getMessage());
                    }
                }
                throw th;
            }
        } catch (Exception unused) {
        }
    }

    public static void writeToSD(String str, String str2, boolean z) {
        try {
            FileWriter fileWriter = new FileWriter(str, z);
            fileWriter.write(str2);
            fileWriter.close();
        } catch (IOException e) {
            b.a(e, c.a("writeToSD IOException: "), "TL");
        }
    }

    public static String MD5(File file, int i) {
        try {
            return a(file, "MD5", i);
        } catch (Exception e) {
            e.getStackTrace();
            Log.e("TL", "Failed to calculate md5 for " + file.getAbsolutePath());
            return "";
        }
    }

    public static String formatSize(long j) {
        if (j >= 1073741824) {
            return formatDecimal(j / 1073741824, 1) + "GB";
        }
        if (j >= 1048576) {
            return formatDecimal(j / 1048576, 1) + "MB";
        }
        return j < 1048576 ? formatDecimal(j / 1024, 1) + "KB" : "";
    }

    public static String getOpCode(Context context, String str, String str2) {
        String str3 = str2 + "/dexdump6 -d " + str;
        StringBuffer stringBuffer = new StringBuffer();
        try {
            Iterator<String> it = runCommand(str3).iterator();
            while (it.hasNext()) {
                stringBuffer.append(it.next().trim() + "\n");
            }
        } catch (IndexOutOfBoundsException e) {
            Log.e("TL", c.a("getOpCode IndexOutOfBoundsException: ").append(e.getMessage()).toString());
        }
        return stringBuffer.toString();
    }

    public static byte[] getOpcodeOptimize(android.content.Context r12, java.lang.String r13, java.lang.String r14) {
        throw new UnsupportedOperationException("Method not decompiled: com.trustlook.sdk.ngsescan.FileUtils.getOpcodeOptimize(android.content.Context, java.lang.String, java.lang.String):byte[]");
    }

    private static boolean a(String str) {
        File file = new File(str);
        return file.exists() && file.isFile();
    }

    private static String a(File file, String str, int i) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance(str);
            try {
                FileInputStream fileInputStream = new FileInputStream(file);
                byte[] bArr = new byte[i];
                while (true) {
                    try {
                        try {
                            int read = fileInputStream.read(bArr);
                            if (read <= 0) {
                                break;
                            }
                            messageDigest.update(bArr, 0, read);
                        } catch (IOException e) {
                            throw new RuntimeException("Unable to process file for MD5", e);
                        }
                    } finally {
                        try {
                            fileInputStream.close();
                        } catch (IOException e2) {
                            Log.e("TL", "Exception on closing MD5 input stream " + e2);
                        }
                    }
                }
                return String.format("%32s", new BigInteger(1, messageDigest.digest()).toString(16)).replace(' ', '0').toUpperCase(Locale.US);
            } catch (FileNotFoundException e3) {
                Log.e("TL", "Exception while getting FileInputStream", e3);
                return null;
            }
        } catch (NoSuchAlgorithmException e4) {
            Log.e("TL", "Exception while getting Digest", e4);
            return null;
        }
    }

    public static String saveDataToFile(String str, String str2) {
        FileOutputStream fileOutputStream;
        File file = new File(str);
        FileOutputStream fileOutputStream2 = null;
        try {
            try {
                try {
                    fileOutputStream = new FileOutputStream(file);
                } catch (Throwable th) {
                    th = th;
                    fileOutputStream2 = fileOutputStream2;
                }
                try {
                    fileOutputStream.write(str2.getBytes());
                    fileOutputStream.close();
                } catch (FileNotFoundException e) {
                    e = e;
                    fileOutputStream2 = fileOutputStream;
                    Log.e("TL", "saveDataToFile FileNotFoundException: " + e.getMessage());
                    if (fileOutputStream2 != null) {
                        fileOutputStream2.close();
                    }
                    return file.getAbsolutePath();
                } catch (IOException e2) {
                    e = e2;
                    fileOutputStream2 = fileOutputStream;
                    Log.e("TL", "saveDataToFile IOException: " + e.getMessage());
                    if (fileOutputStream2 != null) {
                        fileOutputStream2.close();
                    }
                    return file.getAbsolutePath();
                } catch (Throwable th2) {
                    th = th2;
                    fileOutputStream2 = fileOutputStream;
                    if (fileOutputStream2 != null) {
                        try {
                            fileOutputStream2.close();
                        } catch (IOException e3) {
                            b.a(e3, c.a("saveDataToFile IOException: "), "TL");
                        }
                    }
                    throw th;
                }
            } catch (FileNotFoundException e4) {
                e = e4;
            } catch (IOException e5) {
                e = e5;
            } catch (Throwable th3) {
                th = th3;
            }
        } catch (IOException e6) {
            b.a(e6, c.a("saveDataToFile IOException: "), "TL");
        }
        return file.getAbsolutePath();
    }
}