package com.epson.mobilephone.common.license;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.RawRes;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/* renamed from: com.epson.mobilephone.common.license.Util */
public class Util {
    public static String getStringFromRawResource(@NonNull Context context, @RawRes int i) {
        InputStream openRawResource = context.getResources().openRawResource(i);
        try {
            String stringFromInputStream = getStringFromInputStream(openRawResource);
            if (openRawResource != null) {
                try {
                    openRawResource.close();
                } catch (IOException unused) {
                }
            }
            return stringFromInputStream;
        } catch (IOException unused2) {
            if (openRawResource != null) {
                try {
                    openRawResource.close();
                } catch (IOException unused3) {
                }
            }
            return "";
        }
    }

    public static String getStringFromInputStream(InputStream inputStream) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byte[] bArr = new byte[1024];
        while (true) {
            int read = inputStream.read(bArr);
            if (read == -1) {
                return byteArrayOutputStream.toString();
            }
            byteArrayOutputStream.write(bArr, 0, read);
        }
    }
}
