public class StoredEntry
extends java.lang.Object
Stored entries provide the operations that are related to the files themselves, not to the
zip. It is through the StoredEntry class that entries can be deleted (delete(),
open (open()) or realigned (realign()).
Entries are not created directly. They are created using ZFile.add(String, InputStream,
boolean) and obtained from the zip file using ZFile.get(String) or ZFile.entries().
Most of the data in the an entry is in the Central Directory Header. This includes the name,
compression method, file compressed and uncompressed sizes, CRC32 checksum, etc. The CDH can be
obtained using the getCentralDirectoryHeader() method.
| Modifier and Type | Method and Description |
|---|---|
void |
delete()
Deletes this entry from the zip file.
|
CentralDirectoryHeader |
getCentralDirectoryHeader()
Obtains the CDH associated with this entry.
|
DataDescriptorType |
getDataDescriptorType()
Obtains the type of data descriptor used in the entry.
|
ExtraField |
getLocalExtra()
Obtains the contents of the local extra field.
|
int |
getLocalHeaderSize()
Obtains the size of the local header of this entry.
|
StoredEntryType |
getType()
Obtains the type of entry.
|
VerifyLog |
getVerifyLog()
Obtains the verify log for the entry.
|
boolean |
isDeleted()
Returns
true if this entry has been deleted/replaced. |
java.io.InputStream |
open()
Obtains a stream that allows reading from the entry.
|
byte[] |
read()
Obtains the contents of the file.
|
int |
read(byte[] bytes)
Obtains the contents of the file in an existing buffer.
|
boolean |
realign()
Requests that this entry be realigned.
|
void |
setLocalExtra(ExtraField localExtra)
Sets the contents of the local extra field.
|
public int getLocalHeaderSize()
public java.io.InputStream open()
throws java.io.IOException
java.io.IOException - failed to open the streampublic byte[] read()
throws java.io.IOException
java.io.IOException - failed to read the filepublic int read(byte[] bytes)
throws java.io.IOException
bytes - buffer to read the file contents in.java.io.IOException - failed to read the file.public StoredEntryType getType()
public void delete()
throws java.io.IOException
ZFile.update() must be called.java.io.IOException - failed to delete the entryjava.lang.IllegalStateException - if the zip file was open in read-only modepublic boolean isDeleted()
true if this entry has been deleted/replaced.public CentralDirectoryHeader getCentralDirectoryHeader()
public DataDescriptorType getDataDescriptorType()
public boolean realign()
throws java.io.IOException
ZFile then this method does nothing. Otherwise it will move the file's data into
memory and place it in a different area of the zip.java.io.IOException - failed to realign the entry; the entry may no longer exist in the zip file@Nonnull public ExtraField getLocalExtra()
public void setLocalExtra(@Nonnull
ExtraField localExtra)
throws java.io.IOException
localExtra - the contents of the local extra fieldjava.io.IOException - failed to update the zip filepublic VerifyLog getVerifyLog()