Package org.apache.commons.compress.archivers.ar

# Class ArArchiveOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.compress.archivers.ArchiveOutputStream<ArArchiveEntry>
org.apache.commons.compress.archivers.ar.ArArchiveOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

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

This class is not thread-safe

- ## Field Summary

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

  ### Fields inherited from class java.io.FilterOutputStream

  `out`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ArArchiveOutputStream(OutputStream out)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Calls finish if necessary, and then closes the OutputStream
  `void`
  `closeArchiveEntry()`
  Closes the archive entry, writing any trailer information that may be required.
  `ArArchiveEntry`
  `createArchiveEntry(File inputFile, String entryName)`
  Creates an archive entry using the inputFile and entryName provided.
  `ArArchiveEntry`
  `createArchiveEntry(Path inputPath, String entryName, LinkOption... options)`
  Creates an archive entry using the inputPath and entryName provided.
  `void`
  `finish()`
  Finishes the addition of entries to this stream, without closing it.
  `void`
  `putArchiveEntry(ArArchiveEntry entry)`
  Writes the headers for an archive entry to the output stream.
  `void`
  `setLongFileMode(int longFileMode)`
  Sets the long file mode.
  `void`
  `write(byte[] b, int off, int len)`

  ### Methods inherited from class org.apache.commons.compress.archivers.ArchiveOutputStream

  `canWriteEntryData, checkFinished, checkOpen, count, count, getBytesWritten, getCount, isClosed, isFinished, write`

  ### Methods inherited from class java.io.FilterOutputStream

  `flush, write`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### 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 Details

  - ### ArArchiveOutputStream

    public ArArchiveOutputStream(OutputStream out)

- ## Method Details

  - ### close

    public void close() throws IOException
    Calls finish if necessary, and then closes the OutputStream
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Overrides:
      `close` in class `ArchiveOutputStream<ArArchiveEntry>`
    Throws:
      `IOException`

  - ### closeArchiveEntry

    public void closeArchiveEntry() throws IOException
    Description copied from class: `ArchiveOutputStream`
    Closes the archive entry, writing any trailer information that may be required.
    Specified by:
      `closeArchiveEntry` in class `ArchiveOutputStream<ArArchiveEntry>`
    Throws:
      `IOException` - if an I/O error occurs

  - ### createArchiveEntry

    public ArArchiveEntry createArchiveEntry(File inputFile, String entryName) throws 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:
      `IOException` - if an I/O error occurs

  - ### createArchiveEntry

    public ArArchiveEntry createArchiveEntry(Path inputPath, String entryName, LinkOption... options) throws 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:
      `IOException` - if an I/O error occurs
    Since:
      1.21

  - ### finish

    public void finish() throws IOException
    Description copied from class: `ArchiveOutputStream`
    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 `ArchiveOutputStream<ArArchiveEntry>`
    Throws:
      `IOException` - Maybe thrown by subclasses if the user forgets to close the entry.

  - ### putArchiveEntry

    public void putArchiveEntry(ArArchiveEntry entry) throws IOException
    Description copied from class: `ArchiveOutputStream`
    Writes the headers for an archive entry to the output stream. The caller must then write the content to the stream and call `ArchiveOutputStream.closeArchiveEntry()` to complete the process.
    Specified by:
      `putArchiveEntry` in class `ArchiveOutputStream<ArArchiveEntry>`
    Parameters:
      `entry` - describes the entry
    Throws:
      `IOException` - if an I/O error occurs

  - ### 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 IOException
    Overrides:
      `write` in class `FilterOutputStream`
    Throws:
      `IOException`