How can I force a CipherOutputStream to finish encrypting but leave the underlying stream open?
I have a CipherOutputStream backed by another OutputStream. After I have finished writing all the data I need encrypted to the CipherOutputStream, I need to append some unencrypted data. The documentation for CipherOutputStream says that calling flush() will not force the final block out of the encryptor; for that I need to call close() . But close() also closes the underlying OutputStream, which I still need to write more to. How can I force the last block out of the encryptor without closing the stream? Do I need to write my own NonClosingCipherOutputStream? If you don't have a reference to