Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.compress.archivers
Class ArchiveOutputStream

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

All Implemented Interfaces:
  Closeable, Flushable

Direct Known Subclasses:
  ArArchiveOutputStream, CpioArchiveOutputStream, TarArchiveOutputStream, ZipArchiveOutputStream

    public abstract class ArchiveOutputStream

extends OutputStream

Archive output stream implementations are expected to override the `OutputStream.write(byte[], int, int)` method to improve performance. They should also override `OutputStream.close()` to ensure that any necessary trailers are added.

The normal sequence of calls for working with ArchiveOutputStreams is: + create ArchiveOutputStream object + write SFX header (optional, Zip only) + repeat as needed: - putArchiveEntry() (writes entry header) - write() (writes entry data) - closeArchiveEntry() (closes entry) + finish() (ends the addition of entries) + write additional data if format supports it (optional) + close()

Example usage:
TBA

Constructor Summary
`ArchiveOutputStream()`

Method Summary
`abstract void` | `closeArchiveEntry()` Closes the archive entry, writing any trailer information that may be required.
`protected void` | `count(int read)` Increments the counter of already read bytes.
`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.
`int` | `getCount()` Returns the current number of bytes read from 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, write, write`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ArchiveOutputStream

    public ArchiveOutputStream()

Method Detail

### putArchiveEntry

    public abstract void putArchiveEntry(ArchiveEntry entry)
                                  throws IOException

  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
  Throws:
    `IOException`

### closeArchiveEntry

    public abstract void closeArchiveEntry()
                                    throws IOException

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

  Throws:
    `IOException`

### finish

    public abstract void finish()
                         throws IOException

  Finishes the addition of entries to this stream, without closing it. Additional data can be written, if the format supports it. The finish() method throws an Exception if the user forgets to close the entry .

  Throws:
    `IOException`

### createArchiveEntry

    public abstract ArchiveEntry createArchiveEntry(File inputFile,
                                                    String entryName)
                                             throws IOException

  Create an archive entry using the inputFile and entryName provided.

  Parameters:
    `inputFile` -
    `entryName` -
  Returns:
    the ArchiveEntry set up with details from the file
  Throws:
    `IOException`

### write

    public void write(int b)
               throws IOException

  Writes a byte to the current archive entry. This method simply calls write( byte[], 0, 1 ). MUST be overridden if the `OutputStream.write(byte[], int, int)` method is not overridden; may be overridden otherwise.

  Specified by:
    `write` in class `OutputStream`
  Parameters:
    `b` - The byte to be written.
  Throws:
    `IOException` - on error

### count

    protected void count(int read)

  Increments the counter of already read bytes. Doesn't increment if the EOF has been hit (read == -1)

  Parameters:
    `read` - the number of bytes read

### getCount

    public int getCount()

  Returns the current number of bytes read from this stream.

  Returns:
    the number of read bytes

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2009 The Apache Software Foundation. All Rights Reserved.