
While the new implementation is a great simplification and fixes the partial read issue, you can simplify it even further by using java.io.DataInputStream.readFully(). This method is designed for exactly this purpose: reading a specific number of bytes and throwing an EOFException if the end of the stream is reached prematurely. This would make the code more concise and idiomatic, aligning with the goal of this PR.
val data = ByteArray(dataLength)
java.io.DataInputStream(inputStream).readFully(data)
return data
Originally posted by @gemini-code-assist[bot] in #206 (comment)