public class OverwritingZipOutputStreamImpl extends Object implements CustomZipOutputStream.Impl
OutputStream
for zip files that allows newer entries to overwrite
or refresh previously written entries.
This class works by spooling the bytes of each entry to a temporary holding file named after
the name of the ZipEntry
being stored. Once the stream is closed, these files are spooled
off disk and written to the OutputStream given to the constructor.
Constructor and Description |
---|
OverwritingZipOutputStreamImpl(Clock clock,
OutputStream out) |
Modifier and Type | Method and Description |
---|---|
void |
actuallyClose() |
void |
actuallyCloseEntry()
Called by
CustomZipOutputStream.close() and used by impls to close the delegate
stream. |
void |
actuallyPutNextEntry(ZipEntry entry)
Called by
CustomZipOutputStream.putNextEntry(ZipEntry) and used by impls to put the
next entry into the zip file. |
void |
actuallyWrite(byte[] b,
int off,
int len)
Called by
CustomZipOutputStream.write(byte[], int, int) only once it is known that
the stream has not been closed, and that a ZipEntry has already been put on the
stream and not closed. |
public OverwritingZipOutputStreamImpl(Clock clock, OutputStream out)
public void actuallyPutNextEntry(ZipEntry entry) throws IOException
CustomZipOutputStream.Impl
CustomZipOutputStream.putNextEntry(ZipEntry)
and used by impls to put the
next entry into the zip file. It is guaranteed that the entry
won't be null and the
stream will be open. It is also guaranteed that there's no current entry open.actuallyPutNextEntry
in interface CustomZipOutputStream.Impl
entry
- The ZipEntry
to write.IOException
public void actuallyCloseEntry() throws IOException
CustomZipOutputStream.Impl
CustomZipOutputStream.close()
and used by impls to close the delegate
stream. This method will be called at most once in the lifecycle of the
CustomZipOutputStream.actuallyCloseEntry
in interface CustomZipOutputStream.Impl
IOException
public void actuallyWrite(byte[] b, int off, int len) throws IOException
CustomZipOutputStream.Impl
CustomZipOutputStream.write(byte[], int, int)
only once it is known that
the stream has not been closed, and that a ZipEntry
has already been put on the
stream and not closed.actuallyWrite
in interface CustomZipOutputStream.Impl
IOException
public void actuallyClose() throws IOException
actuallyClose
in interface CustomZipOutputStream.Impl
IOException