SpongePowered / nbt

Named Binary Tag (NBT) library for Java based on Graham Edgecombe's JNBT library. NBT is a tag based binary format designed to carry large amounts of binary data with smaller amounts of additional data.
https://flow.github.io/nbt
MIT License
50 stars 33 forks source link

Flushing DataOutputStream before calling toByteArray on the underlying ByteArrayOutputStream #5

Open emopers opened 8 years ago

emopers commented 8 years ago

EndianSwitchableOutputStream.java internally uses DataOutputStream as its stream and when a DataOutputStream instance wraps an underlying ByteArrayOutputStream instance, it is recommended to flush or close the DataOutputStream before invoking the underlying instances's toByteArray(). Also, it is a good practice to call flush/close explicitly as mentioned for example here. This pull request adds a flush method before calling toByteArray().