From 8e347f07615715c68e9ed1444ce1673c4f4fbf85 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Thu, 7 Jul 2022 10:20:34 +0200 Subject: [PATCH] Simpler custom byte array reading. --- pom.xml | 2 +- .../andrewl/record_net/util/ExtendedDataInputStream.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 03e5642..3367e21 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ nl.andrewl record-net - 1.3.1 + 1.3.2 17 diff --git a/src/main/java/nl/andrewl/record_net/util/ExtendedDataInputStream.java b/src/main/java/nl/andrewl/record_net/util/ExtendedDataInputStream.java index 7a6ab0a..768b8e0 100644 --- a/src/main/java/nl/andrewl/record_net/util/ExtendedDataInputStream.java +++ b/src/main/java/nl/andrewl/record_net/util/ExtendedDataInputStream.java @@ -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 {