Ова класа се користи за представљање уноса ЗИП датотеке. Конструктори
ЗипЕнтри (име стринга):
Креира нови зип унос са наведеним именом.
ЗипЕнтри(ЗипЕнтри е) :
Креира нови зип унос са пољима преузетим из наведеног зип уноса. Методе:
Објецт цлоне():
Returns a copy of this entry.
Syntax : public Object clone() Overrides: clone in class Object Returns: a clone of this instance.
Стринг гетЦоммент() :
Returns the comment string for the entry or null if none.
Syntax : public String getComment() Returns: the comment string for the entry or null if none
лонг гетЦомпресседСизе() :
Returns the size of the compressed entry data or -1 if not known.In the case of a stored entry the compressed size will be the same as the uncompressed size of the entry.
Syntax : public long getCompressedSize() Returns: the size of the compressed entry data or -1 if not known
лонг гетЦрц() :
Returns the CRC-32 checksum of the uncompressed entry data or -1 if not known.
Syntax : public long getCrc() Returns: the CRC-32 checksum of the uncompressed entry data or -1 if not known
бајт[] гетЕктра() :
Returns the extra field data for the entry or null if none.
Syntax : =public byte[] getExtra() Returns: the extra field data for the entry or null if none
инт гетМетход() :
Returns the compression method of the entry or -1 if not specified.
Syntax : public int getMethod() Returns: the compression method of the entry or -1 if not specified
Стринг гетНаме() :
Returns the name of the entry.
Syntax : public String getName() Returns: the name of the entry
лонг гетСизе():
Returns the uncompressed size of the entry data or -1 if not known.
Syntax : public long getSize() Returns: the uncompressed size of the entry data or -1 if not know
лонг гетТиме():
Returns the modification time of the entry or -1 if not specified.
Syntax : public long getTime() Returns: the modification time of the entry or -1 if not specified
инт хасхЦоде() :
Returns the hash code value for this entry.
Syntax : public int hashCode() Overrides: hashCode in class Object Returns: a hash code value for this object.
боолеан исДирецтори() :
Returns true if this is a directory entry. A directory entry is defined to be one whose name ends with a '/'.
Syntax : public boolean isDirectory() Returns: true if this is a directory entry
воид сетЦоммент(стринг коментар):
Sets the optional comment string for the entry.ZIP entry comments have maximum length of 0xffff. If the length of the specified comment string is greater than 0xFFFF bytes after encoding only the first 0xFFFF bytes are output to the ZIP file entry.
Syntax : public void setComment(String comment) Parameters: comment - the comment string
воид сетЦомпресседСизе (дуга цсизе) :
Sets the size of the compressed entry data.
Syntax : public void setCompressedSize(long csize) Parameters: csize - the compressed size to set to
воид сетЦрц(лонг црц) :
Sets the CRC-32 checksum of the uncompressed entry data.
Syntax : public void setCrc(long crc) Parameters: crc - the CRC-32 value Throws: IllegalArgumentException
воид сетЕктра(бите[] ектра) :
Sets the optional extra field data for the entry.
Syntax : public void setExtra(byte[] extra) Parameters: extra - the extra field data bytes Throws: IllegalArgumentException
воид сетМетход(инт метход) :
Sets the compression method for the entry.
Syntax : public void setMethod(int method) Parameters: method - the compression method either STORED or DEFLATED Throws: IllegalArgumentException
воид сетСизе (дуга величина) :
Sets the uncompressed size of the entry data.
Syntax : public void setSize(long size) Parameters: size - the uncompressed size in bytes Throws: IllegalArgumentException
воид сетТиме (дуго време):
Sets the modification time of the entry.
Syntax : public void setTime(long time) Parameters: time - the entry modification time in number of milliseconds since the epoch
Стринг тоСтринг() :
Returns a string representation of the ZIP entry.
Syntax : public String toString() Overrides: toString in class Object Returns: a string representation of the object.
Програм: Java
//Java program demonstrating ZipEntry methodsimportjava.io.FileInputStream;importjava.io.IOException;importjava.io.PrintStream;importjava.nio.file.attribute.FileTime;importjava.util.concurrent.TimeUnit;importjava.util.zip.ZipEntry;importjava.util.zip.ZipInputStream;classZipEntryDemo{publicstaticvoidmain(String[]args)throwsIOException{FileInputStreamfis=newFileInputStream('Awesome CV.zip');ZipInputStreamjis=newZipInputStream(fis);PrintStreamcout=System.out;//reading the next ZIP file entryZipEntryze=jis.getNextEntry();//illustrating getName()cout.println(ze.getName());//illustrating getComment()ze.setComment('This is a comment');cout.println(ze.getComment());//illustrating setCompressedSize() and getCompressedSize()ze.setCompressedSize(23l);cout.println('CompressedSize of the entry = '+ze.getCompressedSize());//illustrating getSize() and setSize()ze.setSize(53l);cout.println('Size = '+ze.getSize());//illustrating getCrc() and setCrc()ze.setCrc(01);cout.println(ze.getCrc());//illustrating getMethod and setMethodze.setMethod(ZipEntry.STORED);cout.println(ze.getMethod());//illustrating getCreation and setCreation()ze.setCreationTime(FileTime.from(10000TimeUnit.DAYS));cout.println(ze.getCreationTime());//illustrating getLastAccessTime and setLastAccessTimeze.setLastAccessTime(FileTime.from(1000TimeUnit.DAYS));cout.println(ze.getLastAccessTime());//illustrating clone()ZipEntryzeclone=(ZipEntry)ze.clone();cout.println(zeclone.getName());//illustrating isDirectorycout.println(ze.isDirectory());//illustrating hashcode()cout.println('hashcode = '+ze.hashCode());}}
Излаз :
awesome-cv.cls This is a comment CompressedSize of the entry = 23 Size = 53 1 0 1997-05-19T00:00:00Z 1972-09-27T00:00:00Z awesome-cv.cls false hashcode = 1687382489