C1073Util.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.epson.mobilephone.common.license;
  2. import android.content.Context;
  3. import android.support.annotation.RawRes;
  4. import java.io.ByteArrayOutputStream;
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7. /* renamed from: com.epson.mobilephone.common.license.Util */
  8. public class C1073Util {
  9. public static String getStringFromRawResource(@NonNull Context context, @RawRes int i) {
  10. InputStream openRawResource = context.getResources().openRawResource(i);
  11. try {
  12. String stringFromInputStream = getStringFromInputStream(openRawResource);
  13. if (openRawResource != null) {
  14. try {
  15. openRawResource.close();
  16. } catch (IOException unused) {
  17. }
  18. }
  19. return stringFromInputStream;
  20. } catch (IOException unused2) {
  21. if (openRawResource != null) {
  22. try {
  23. openRawResource.close();
  24. } catch (IOException unused3) {
  25. }
  26. }
  27. return "";
  28. }
  29. }
  30. public static String getStringFromInputStream(InputStream inputStream) throws IOException {
  31. ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
  32. byte[] bArr = new byte[1024];
  33. while (true) {
  34. int read = inputStream.read(bArr);
  35. if (read == -1) {
  36. return byteArrayOutputStream.toString();
  37. }
  38. byteArrayOutputStream.write(bArr, 0, read);
  39. }
  40. }
  41. }