alexandroid/decompiled/jadx/sources/com/amazonaws/util/IOUtils.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

70 lines
2.2 KiB
Java

package com.amazonaws.util;
import com.amazonaws.logging.Log;
import com.amazonaws.logging.LogFactory;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes6.dex */
public enum IOUtils {
;
private static final int BUFFER_SIZE = 4096;
private static final Log logger = LogFactory.getLog((Class<?>) IOUtils.class);
public static void closeQuietly(Closeable closeable, Log log) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
if (logger.isDebugEnabled()) {
logger.debug("Ignore failure in closing the Closeable", e);
}
}
}
}
public static long copy(InputStream inputStream, OutputStream outputStream) throws IOException {
byte[] bArr = new byte[4096];
long j = 0;
while (true) {
int read = inputStream.read(bArr);
if (read <= -1) {
return j;
}
outputStream.write(bArr, 0, read);
j += read;
}
}
public static void release(Closeable closeable, Log log) {
closeQuietly(closeable, log);
}
public static byte[] toByteArray(InputStream inputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
byte[] bArr = new byte[4096];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
byte[] byteArray = byteArrayOutputStream.toByteArray();
byteArrayOutputStream.close();
return byteArray;
}
byteArrayOutputStream.write(bArr, 0, read);
}
} catch (Throwable th) {
byteArrayOutputStream.close();
throw th;
}
}
public static String toString(InputStream inputStream) throws IOException {
return new String(toByteArray(inputStream), StringUtils.UTF8);
}
}