/** * Close the TarBuffer. If this is an output buffer, also flush the * current block before closing. * @throws IOException on error */ public void close() throws IOException { if (debug) { System.err.println("TarBuffer.closeBuffer()."); } if (outStream != null) { flushBlock(); if (outStream != System.out && outStream != System.err) { outStream.close(); outStream = null; } } else if (inStream != null) { if (inStream != System.in) { inStream.close(); } inStream = null; } } }
/** * 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; }