org.apache.commons.compress.archivers.ar
Class ArArchiveOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.commons.compress.archivers.ArchiveOutputStream
          extended by org.apache.commons.compress.archivers.ar.ArArchiveOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class ArArchiveOutputStream
extends ArchiveOutputStream

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


Field Summary
private  long archiveOffset
           
private  long entryOffset
           
private  boolean finished
          indicates if this archive is finished
private  boolean haveUnclosedEntry
           
private  java.io.OutputStream out
           
private  ArArchiveEntry prevEntry
           
 
Constructor Summary
ArArchiveOutputStream(java.io.OutputStream pOut)
           
 
Method Summary
 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.
private  long fill(long pOffset, long pNewOffset, char pFill)
           
 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 write(byte[] b, int off, int len)
           
private  long write(java.lang.String data)
           
private  long writeArchiveHeader()
           
private  long writeEntryHeader(ArArchiveEntry pEntry)
           
 
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

out

private final java.io.OutputStream out

archiveOffset

private long archiveOffset

entryOffset

private long entryOffset

prevEntry

private ArArchiveEntry prevEntry

haveUnclosedEntry

private boolean haveUnclosedEntry

finished

private boolean finished
indicates if this archive is finished

Constructor Detail

ArArchiveOutputStream

public ArArchiveOutputStream(java.io.OutputStream pOut)
Method Detail

writeArchiveHeader

private long writeArchiveHeader()
                         throws java.io.IOException
Throws:
java.io.IOException

closeArchiveEntry

public void closeArchiveEntry()
                       throws java.io.IOException
Closes the archive entry, writing any trailer information that may be required.

Specified by:
closeArchiveEntry in class ArchiveOutputStream
Throws:
java.io.IOException

putArchiveEntry

public void putArchiveEntry(ArchiveEntry pEntry)
                     throws java.io.IOException
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

fill

private long fill(long pOffset,
                  long pNewOffset,
                  char pFill)
           throws java.io.IOException
Throws:
java.io.IOException

write

private long write(java.lang.String data)
            throws java.io.IOException
Throws:
java.io.IOException

writeEntryHeader

private long writeEntryHeader(ArArchiveEntry pEntry)
                       throws java.io.IOException
Throws:
java.io.IOException

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
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
Create an archive entry using the inputFile and entryName provided.

Specified by:
createArchiveEntry in class ArchiveOutputStream
Returns:
the ArchiveEntry set up with details from the file
Throws:
java.io.IOException

finish

public void finish()
            throws java.io.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 .

Specified by:
finish in class ArchiveOutputStream
Throws:
java.io.IOException