Fix the buffer size in the getBytesFromStream function

This commit is contained in:
Maschell 2019-04-07 00:38:51 +02:00
parent a5bc706cb9
commit 31fcc4fc6d

View File

@ -35,7 +35,12 @@ public final class StreamUtils {
public static byte[] getBytesFromStream(InputStream in, int size) throws IOException { public static byte[] getBytesFromStream(InputStream in, int size) throws IOException {
synchronized (in) { synchronized (in) {
byte[] result = new byte[size]; byte[] result = new byte[size];
byte[] buffer = new byte[0x8000]; byte[] buffer = null;
if (size < 0x8000) {
buffer = new byte[size];
} else {
buffer = new byte[0x8000];
}
int totalRead = 0; int totalRead = 0;
do { do {
int read = in.read(buffer); int read = in.read(buffer);