Simpler custom byte array reading.

This commit is contained in:
Andrew Lalis 2022-07-07 10:20:34 +02:00
parent e68f496302
commit 8e347f0761
2 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@
<groupId>nl.andrewl</groupId>
<artifactId>record-net</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>

View File

@ -56,7 +56,12 @@ public class ExtendedDataInputStream extends DataInputStream {
public byte[] readByteArray() throws IOException {
int length = readInt();
if (length < 0) return null;
return readNBytes(length);
byte[] array = new byte[length];
int readCount = read(array, 0, length);
while (readCount < length) {
readCount += read(array, readCount, length - readCount);
}
return array;
}
public int[] readIntArray() throws IOException {