E - The type of ArchiveEntry consumed.public abstract class ArchiveOutputStream<E extends ArchiveEntry>
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 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.
|
abstract E |
createArchiveEntry(java.io.File inputFile,
java.lang.String entryName)
Creates an archive entry using the inputFile and entryName provided.
|
E |
createArchiveEntry(java.nio.file.Path inputPath,
java.lang.String entryName,
java.nio.file.LinkOption... options)
Creates an archive entry using the inputPath and entryName provided.
|
abstract void |
finish()
Finishes the addition of entries to this stream, without closing it.
|
long |
getBytesWritten()
Gets 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(E entry)
Writes the headers for an archive entry to the output stream.
|
void |
write(int b)
Writes a byte to the current archive entry.
|
public boolean canWriteEntryData(ArchiveEntry archiveEntry)
Some archive formats support variants or details that are not supported (yet).
archiveEntry - the entry to testpublic abstract void closeArchiveEntry()
throws java.io.IOException
java.io.IOException - if an I/O error occurspublic abstract E createArchiveEntry(java.io.File inputFile, java.lang.String entryName) throws java.io.IOException
inputFile - the file to create the entry fromentryName - name to use for the entryjava.io.IOException - if an I/O error occurspublic E createArchiveEntry(java.nio.file.Path inputPath, java.lang.String entryName, java.nio.file.LinkOption... options) throws java.io.IOException
The default implementation calls simply delegates as:
return createArchiveEntry(inputFile.toFile(), entryName);
Subclasses should override this method.
inputPath - the file to create the entry fromentryName - name to use for the entryoptions - options indicating how symbolic links are handled.java.io.IOException - if an I/O error occurspublic abstract void finish()
throws java.io.IOException
java.io.IOException - if the user forgets to close the entry.public long getBytesWritten()
@Deprecated public int getCount()
public abstract void putArchiveEntry(E entry) throws java.io.IOException
closeArchiveEntry()
to complete the process.entry - describes the entryjava.io.IOException - if an I/O error occurspublic void write(int b)
throws java.io.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 java.io.OutputStreamb - The byte to be written.java.io.IOException - on errorCopyright © 2010 - 2024 Adobe. All Rights Reserved