-
- All Implemented Interfaces:
-
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public abstract class ArchiveOutputStream extends OutputStream
Archive output stream implementations are expected to override the write method to improve performance. They should also override close to ensure that any necessary trailers are added.
The normal sequence of calls when working with ArchiveOutputStreams is:
- Create ArchiveOutputStream object,
- optionally write SFX header (Zip only),
- repeat as needed:
- putArchiveEntry (writes entry header),
- write (writes entry data, as often as needed),
- closeArchiveEntry (closes entry),
- finish (ends the addition of entries),
- optionally write additional data, provided format supports it,
- close.
-
-
Field Summary
Fields Modifier and Type Field Description private longbytesWritten
-
Method Summary
Modifier and Type Method Description longgetBytesWritten()Returns the current number of bytes written to this stream. booleancanWriteEntryData(ArchiveEntry archiveEntry)Whether this stream is able to write the given entry. abstract voidcloseArchiveEntry()Closes the archive entry, writing any trailer information that maybe required. abstract ArchiveEntrycreateArchiveEntry(File inputFile, String entryName)Create an archive entry using the inputFile and entryName provided. abstract voidfinish()Finishes the addition of entries to this stream, without closing it.Additional data can be written, if the format supports it. intgetCount()Returns the current number of bytes written to this stream. abstract voidputArchiveEntry(ArchiveEntry entry)Writes the headers for an archive entry to the output stream. voidwrite(int b)Writes a byte to the current archive entry. -
-
Method Detail
-
getBytesWritten
long getBytesWritten()
Returns the current number of bytes written to this stream.
-
canWriteEntryData
boolean canWriteEntryData(ArchiveEntry archiveEntry)
Whether this stream is able to write the given entry.
Some archive formats support variants or details that arenot supported (yet).
- Parameters:
archiveEntry- the entry to test
-
closeArchiveEntry
abstract void closeArchiveEntry()
Closes the archive entry, writing any trailer information that maybe required.
-
createArchiveEntry
abstract ArchiveEntry createArchiveEntry(File inputFile, String entryName)
Create an archive entry using the inputFile and entryName provided.
- Parameters:
inputFile- the file to create the entry fromentryName- name to use for the entry
-
finish
abstract void finish()
Finishes the addition of entries to this stream, without closing it.Additional data can be written, if the format supports it.
-
getCount
@Deprecated() int getCount()
Returns the current number of bytes written to this stream.
-
putArchiveEntry
abstract void putArchiveEntry(ArchiveEntry entry)
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
-
-
-
-