ArArchiveOutputStream
Date: 2017-02-08

org.apache.commons.compress.archivers.ar

## Class ArArchiveOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - org.apache.commons.compress.archivers.ArchiveOutputStream
    - - org.apache.commons.compress.archivers.ar.ArArchiveOutputStream

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

      public class ArArchiveOutputStream
      extends ArchiveOutputStream

  Implements the "ar" archive format as an output stream.

- - ### Field Summary

    Fields
    Modifier and Type | Field and 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 and Description
    `ArArchiveOutputStream(java.io.OutputStream pOut)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and 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.
    `ArchiveEntry` | `createArchiveEntry(java.io.File inputFile, java.lang.String entryName)` Create an archive entry using the inputFile and entryName provided.
    `void` | `finish()` Finishes the addition of entries to this stream, without closing it.
    `void` | `putArchiveEntry(ArchiveEntry pEntry)` Writes the headers for an archive entry to the output stream.
    `void` | `setLongFileMode(int longFileMode)` Set the long file mode.
    `void` | `write(byte[] b, int off, int len)`

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

      `canWriteEntryData, count, count, getBytesWritten, getCount, write`

    - ### Methods inherited from class java.io.OutputStream

      `flush, write`

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

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

- - ### 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 pOut)

  - ### Method Detail

    - #### setLongFileMode

          public void setLongFileMode(int longFileMode)

      Set 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

    - #### closeArchiveEntry

          public void closeArchiveEntry()
                                 throws java.io.IOException

      Description copied from class: `ArchiveOutputStream`
      Closes the archive entry, writing any trailer information that may be required.
      Specified by:
        `closeArchiveEntry` in class `ArchiveOutputStream`
      Throws:
        `java.io.IOException` - if an I/O error occurs

    - #### putArchiveEntry

          public void putArchiveEntry(ArchiveEntry pEntry)
                               throws java.io.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`
      Parameters:
        `pEntry` - describes the entry
      Throws:
        `java.io.IOException` - if an I/O error occurs

    - #### write

          public void write(byte[] b,
                   int off,
                   int len)
                     throws java.io.IOException

      Overrides:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Calls finish if necessary, and then closes the OutputStream
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### createArchiveEntry

          public ArchiveEntry createArchiveEntry(java.io.File inputFile,
                                        java.lang.String entryName)
                                          throws java.io.IOException

      Description copied from class: `ArchiveOutputStream`
      Create an archive entry using the inputFile and entryName provided.
      Specified by:
        `createArchiveEntry` in class `ArchiveOutputStream`
      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

    - #### finish

          public void finish()
                      throws java.io.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.
      Specified by:
        `finish` in class `ArchiveOutputStream`
      Throws:
        `java.io.IOException` - if the user forgets to close the entry.