You should always close the outermost stream (in this case, mybis), and close it before any others. Closing the other stream after that is optional - you con't really need to because the each outer stream will close the next stream inside it. But if you want to close the inner streams too, that doesn't do any harm. If you close inner streams before outer streams though, you may get an exception. That's particularly true for output streams.