devutility.internal.io.StreamUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of devutility.internal Show documentation
Show all versions of devutility.internal Show documentation
Utilities for Java development
package devutility.internal.io;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
public class StreamUtils {
public static byte[] read(InputStream inputStream) {
int index = 0;
byte[] bytes = new byte[1024];
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
while ((index = inputStream.read(bytes, 0, bytes.length)) > 0) {
byteArrayOutputStream.write(bytes, 0, index);
}
return byteArrayOutputStream.toByteArray();
} catch (Exception e) {
System.out.println(e.toString());
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy