I was helping a friend to write some Java code, who doesn\'t know a lot about Java. So I wrote him some helper functions to easily get things done that are a little quirky i
Do what Stas Kurilin suggests.
In general, streams should be closed by the party that opened/created them.
In your method, just flush the stream. Close it wherever it was opened when it is no longer needed.