Package 

Class ArchiveOutputStream

  • All Implemented Interfaces:
    java.io.Closeable , java.io.Flushable , java.lang.AutoCloseable

    
    public abstract class ArchiveOutputStream
    extends OutputStream
                        

    Archive output stream implementations are expected to override the write method to improve performance. They should also override close to ensure that any necessary trailers are added.

    The normal sequence of calls when working with ArchiveOutputStreams is:

    • Create ArchiveOutputStream object,
    • optionally write SFX header (Zip only),
    • repeat as needed:
    • finish (ends the addition of entries),
    • optionally write additional data, provided format supports it,
    • close.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long bytesWritten
    • Method Summary

      Modifier and Type Method Description
      long getBytesWritten() Returns the current number of bytes written to this stream.
      boolean canWriteEntryData(ArchiveEntry archiveEntry) Whether this stream is able to write the given entry.
      abstract void closeArchiveEntry() Closes the archive entry, writing any trailer information that maybe required.
      abstract ArchiveEntry createArchiveEntry(File inputFile, String entryName) Create an archive entry using the inputFile and entryName provided.
      abstract void finish() Finishes the addition of entries to this stream, without closing it.Additional data can be written, if the format supports it.
      int getCount() Returns the current number of bytes written to this stream.
      abstract void putArchiveEntry(ArchiveEntry entry) Writes the headers for an archive entry to the output stream.
      void write(int b) Writes a byte to the current archive entry.
      • Methods inherited from class java.io.OutputStream

        close, flush, nullOutputStream, write
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getBytesWritten

         long getBytesWritten()

        Returns the current number of bytes written to this stream.

      • canWriteEntryData

         boolean canWriteEntryData(ArchiveEntry archiveEntry)

        Whether this stream is able to write the given entry.

        Some archive formats support variants or details that arenot supported (yet).

        Parameters:
        archiveEntry - the entry to test
      • closeArchiveEntry

         abstract void closeArchiveEntry()

        Closes the archive entry, writing any trailer information that maybe required.

      • createArchiveEntry

         abstract ArchiveEntry createArchiveEntry(File inputFile, String entryName)

        Create an archive entry using the inputFile and entryName provided.

        Parameters:
        inputFile - the file to create the entry from
        entryName - name to use for the entry
      • finish

         abstract void finish()

        Finishes the addition of entries to this stream, without closing it.Additional data can be written, if the format supports it.

      • getCount

        @Deprecated() int getCount()

        Returns the current number of bytes written to this stream.

      • putArchiveEntry

         abstract void putArchiveEntry(ArchiveEntry entry)

        Writes the headers for an archive entry to the output stream.The caller must then write the content to the stream and call closeArchiveEntry to complete the process.

        Parameters:
        entry - describes the entry
      • write

         void write(int b)

        Writes a byte to the current archive entry.

        This method simply calls {@code write( byte[], 0, 1 )}.

        MUST be overridden if the write methodis not overridden; may be overridden otherwise.

        Parameters:
        b - The byte to be written.