Skip to content

Enhance readability of readAhead function in TLV decoders #209

@keiji

Description

@keiji

medium

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions