An IOException out of this could cause the OutputStream to not be closed.

Try out Guava Closer, it's a thing you can register multiple things on and then close in an exception safe manner.