Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Wajihulhassan/eca620a5d0199ad9f3534a7d57576392 to your computer and use it in GitHub Desktop.
Save Wajihulhassan/eca620a5d0199ad9f3534a7d57576392 to your computer and use it in GitHub Desktop.
Closing OutputStream before calling toByteArray on the underlying ByteArrayOutputStream
When a `DataOutputStream` or an `ObjectOutputStream` instance wraps an underlying ByteArrayOutputStream instance,
it is recommended to flush or close the DataOutputStream and ObjectOutputStream before invoking the
underlying instances's toByteArray(). Also, it is a good practice to call flush/close explicitly
as mentioned for example [here] (http://stackoverflow.com/questions/2984538/how-to-use-bytearrayoutputstream-and-dataoutputstream-simultaneously-java).
This pull request adds a `flush` method before calling toByteArray().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment