Class ArArchiveOutputStream

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

    public class ArArchiveOutputStream
    extends ArchiveOutputStream<ArArchiveEntry>
    Implements the "ar" archive format as an output stream.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int LONGFILE_BSD
      BSD ar extensions are used to store long file names in the archive.
      static int LONGFILE_ERROR
      Fail if a long file name is required in the archive.
    • Constructor Summary

      Constructors 
      Constructor Description
      ArArchiveOutputStream​(java.io.OutputStream out)
      Constructs a new instance with the given backing OutputStream.
    • Field Detail

      • LONGFILE_ERROR

        public static final int LONGFILE_ERROR
        Fail if a long file name is required in the archive.
        See Also:
        Constant Field Values
      • LONGFILE_BSD

        public static final int LONGFILE_BSD
        BSD ar extensions are used to store long file names in the archive.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ArArchiveOutputStream

        public ArArchiveOutputStream​(java.io.OutputStream out)
        Constructs a new instance with the given backing OutputStream.
        Parameters:
        out - the underlying output stream to be assigned to the field this.out for later use, or null if this instance is to be created without an underlying stream.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Calls finish if necessary, and then closes the OutputStream
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class CompressFilterOutputStream<java.io.OutputStream>
        Throws:
        java.io.IOException
      • createArchiveEntry

        public ArArchiveEntry createArchiveEntry​(java.io.File inputFile,
                                                 java.lang.String entryName)
                                          throws java.io.IOException
        Description copied from class: ArchiveOutputStream
        Creates an archive entry using the inputFile and entryName provided.
        Specified by:
        createArchiveEntry in class ArchiveOutputStream<ArArchiveEntry>
        Parameters:
        inputFile - the file to create the entry from
        entryName - name to use for the entry
        Returns:
        the ArchiveEntry set up with details from the file
        Throws:
        java.io.IOException - if an I/O error occurs
      • createArchiveEntry

        public ArArchiveEntry createArchiveEntry​(java.nio.file.Path inputPath,
                                                 java.lang.String entryName,
                                                 java.nio.file.LinkOption... options)
                                          throws java.io.IOException
        Creates an archive entry using the inputPath and entryName provided.

        The default implementation calls simply delegates as:

         return createArchiveEntry(inputFile.toFile(), entryName);
         

        Subclasses should override this method.

        Overrides:
        createArchiveEntry in class ArchiveOutputStream<ArArchiveEntry>
        Parameters:
        inputPath - the file to create the entry from
        entryName - name to use for the entry
        options - options indicating how symbolic links are handled.
        Returns:
        the ArchiveEntry set up with details from the file
        Throws:
        java.io.IOException - if an I/O error occurs
        Since:
        1.21
      • finish

        public void finish()
                    throws java.io.IOException
        Description copied from class: CompressFilterOutputStream
        Finishes the addition of entries to this stream, without closing it. Additional data can be written, if the format supports it.
        Overrides:
        finish in class CompressFilterOutputStream<java.io.OutputStream>
        Throws:
        java.io.IOException - Maybe thrown by subclasses if the user forgets to close the entry.
      • setLongFileMode

        public void setLongFileMode​(int longFileMode)
        Sets the long file mode. This can be LONGFILE_ERROR(0) or LONGFILE_BSD(1). This specifies the treatment of long file names (names >= 16). Default is LONGFILE_ERROR.
        Parameters:
        longFileMode - the mode to use
        Since:
        1.3
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException