/** * Overrides the {@link OutputStream#close()}. Closes this output stream and * releases any system resources associated with this stream. * * @throws IOException if an I/O error occurs. */ @Override public void close() throws IOException { if (closed) { return; } try { encryptFinal(); output.close(); freeBuffers(); cipher.close(); super.close(); } finally { closed = true; } }