/** * Ends the TAR archive without closing the underlying OutputStream. * * An archive consists of a series of file entries terminated by an * end-of-archive entry, which consists of two 512 blocks of zero bytes. * POSIX.1 requires two EOF records, like some other implementations. * * @throws IOException on error */ public void finish() throws IOException { if (finished) { throw new IOException("This archive has already been finished"); } if (haveUnclosedEntry) { throw new IOException("This archives contains unclosed entries."); } writeEOFRecord(); writeEOFRecord(); buffer.flushBlock(); finished = true; }