public abstract class ArchiveOutputStream extends 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 when working with ArchiveOutputStreams is:
putArchiveEntry(ArchiveEntry)
(writes entry header),
OutputStream.write(byte[])
(writes entry data, as often as needed),
closeArchiveEntry()
(closes entry),
finish()
(ends the addition of entries),OutputStream.close()
.Constructor and Description |
---|
ArchiveOutputStream() |
Modifier and Type | Method and Description |
---|---|
boolean |
canWriteEntryData(ArchiveEntry archiveEntry)
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(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.
|
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.
|
close, flush, write, write
public ArchiveOutputStream()
public abstract void putArchiveEntry(ArchiveEntry entry) throws IOException
closeArchiveEntry()
to complete the process.entry
- describes the entryIOException
- if an I/O error occurspublic abstract void closeArchiveEntry() throws IOException
IOException
- if an I/O error occurspublic abstract void finish() throws IOException
IOException
- if the user forgets to close the entry.public abstract ArchiveEntry createArchiveEntry(File inputFile, String entryName) throws IOException
inputFile
- the file to create the entry fromentryName
- name to use for the entryIOException
- if an I/O error occurspublic void write(int b) throws IOException
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.
write
in class OutputStream
b
- The byte to be written.IOException
- on errorprotected void count(int written)
written == -1
).written
- the number of bytes writtenprotected void count(long written)
written == -1
).written
- the number of bytes written@Deprecated public int getCount()
public long getBytesWritten()
public boolean canWriteEntryData(ArchiveEntry archiveEntry)
Some archive formats support variants or details that are not supported (yet).
archiveEntry
- the entry to testCopyright © 2016 The Apache Software Foundation. All rights reserved.