com.github.kugelsoft.paramscanner.util.BytesUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kugel-param-scanner-maven-plugin Show documentation
Show all versions of kugel-param-scanner-maven-plugin Show documentation
A maven plugin to scan the parameters of Kugel WEB-ERP.
package com.github.kugelsoft.paramscanner.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class BytesUtil {
public static final byte[] EMPTY_ARRAY = new byte[0];
private BytesUtil() {
}
public static byte[] readAllBytes(InputStream inputStream) {
try {
final int bufLen = 10240;
byte[] buf = new byte[bufLen];
int readLen;
IOException exception = null;
try {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
while ((readLen = inputStream.read(buf, 0, bufLen)) != -1)
outputStream.write(buf, 0, readLen);
return outputStream.toByteArray();
}
} catch (IOException e) {
exception = e;
throw e;
} finally {
if (exception == null)
inputStream.close();
else
try {
inputStream.close();
} catch (IOException e) {
exception.addSuppressed(e);
}
}
} catch (Exception ex) {
throw new RuntimeException(ex.getMessage(), ex);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy