org.apache.commons.compress.archivers
public abstract class ArchiveOutputStream extends java.io.OutputStream
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
Modifier and Type | Field and Description |
---|---|
(package private) static int |
BYTE_MASK |
private long |
bytesWritten
holds the number of bytes written to this stream
|
private byte[] |
oneByte
Temporary buffer used for the
write(int) method |
Constructor and Description |
---|
ArchiveOutputStream() |
Modifier and Type | Method and Description |
---|---|
boolean |
canWriteEntryData(ArchiveEntry ae)
Whether this stream is able to write the given entry.
|
abstract void |
closeArchiveEntry()
Closes the archive entry, writing any trailer information that may
be required.
|
protected void |
count(int written)
Increments the counter of already written bytes.
|
protected void |
count(long written)
Increments the counter of already written bytes.
|
abstract ArchiveEntry |
createArchiveEntry(java.io.File inputFile,
java.lang.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.
|
long |
getBytesWritten()
Returns the current number of bytes written to this stream.
|
int |
getCount()
Deprecated.
this method may yield wrong results for large
archives, use #getBytesWritten instead
|
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.
|
private final byte[] oneByte
write(int)
methodstatic final int BYTE_MASK
private long bytesWritten
public abstract void putArchiveEntry(ArchiveEntry entry) throws java.io.IOException
closeArchiveEntry()
to complete the process.entry
- describes the entryjava.io.IOException
public abstract void closeArchiveEntry() throws java.io.IOException
java.io.IOException
public abstract void finish() throws java.io.IOException
java.io.IOException
public abstract ArchiveEntry createArchiveEntry(java.io.File inputFile, java.lang.String entryName) throws java.io.IOException
inputFile
- entryName
- java.io.IOException
public void write(int b) throws java.io.IOException
OutputStream.write(byte[], int, int)
method
is not overridden; may be overridden otherwise.write
in class java.io.OutputStream
b
- The byte to be written.java.io.IOException
- on errorprotected void count(int written)
written
- the number of bytes writtenprotected void count(long written)
written
- the number of bytes writtenpublic int getCount()
public long getBytesWritten()
public boolean canWriteEntryData(ArchiveEntry ae)
Some archive formats support variants or details that are not supported (yet).
This implementation always returns true.