package cn.yyxx.commsdk.core.utils;

import android.content.Context;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author #Suyghur.
 * Created on 2021/10/15
 */
public class FileUtils {

    public static String readAssetsFileByKey(Context context, String fileName, String key) {
        String value = "";
        InputStream is = null;
        try {
            is = context.getAssets().open(fileName);
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
            String temp = "";
            while ((temp = bufferedReader.readLine()) != null) {
                if (temp.contains(key)) {
                    value = temp.substring(temp.indexOf("=") + 1);
                    break;
                }
            }
            bufferedReader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return value;
    }
}
