package it.integry.integrywmsnative.core.utility;

import android.content.Context;
import androidx.annotation.RawRes;

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

public class UtilityResources {

    private static Context mContext;

    public static void init(Context context) {
        mContext = context;
    }

    public static String readRawTextFile(@RawRes int resId) {
        InputStream inputStream = mContext.getResources().openRawResource(resId);

        InputStreamReader inputreader = new InputStreamReader(inputStream);
        BufferedReader buffreader = new BufferedReader(inputreader);
        String line;
        StringBuilder text = new StringBuilder();

        try {
            while (( line = buffreader.readLine()) != null) {
                text.append(line);
                text.append('\n');
            }
        } catch (IOException e) {
            return null;
        }
        return text.toString();
    }

}
