Цей клас використовується для представлення запису файлу JAR. Конструктори:
JarEntry(JarEntry їсти) :
Створює новий JarEntry з полями, взятими з указаного об’єкта JarEntry.
JarEntry (ім'я рядка):
Створює новий запис JarEntry для вказаного імені запису файлу JAR.
JarEntry(ZipEntry з):
Створює новий JarEntry з полями, взятими з указаного об’єкта ZipEntry. Методи:
Атрибути getAttributes() :
Returns the Manifest Attributes for this entry or null if none.
Syntax : public Attributes getAttributes() throws IOException Returns: the Manifest Attributes for this entry or null if none
Certificate[] getCertificates() :
Returns the Certificate objects for this entry or null if none.
Syntax : public Certificate[] getCertificates() Returns: the Certificate objects for this entry or null if none.
CodeSigner[] getCodeSigners() :
Returns the CodeSigner objects for this entry or null if none.
Syntax : public CodeSigner[] getCodeSigners() Returns: the CodeSigner objects for this entry or null if none.
Методи, успадковані від класу java.util.zip.ZipEntry clone getComment getCompressedSize getCrc getExtra getMethod getName getSize getTime hashCode isDirectory setComment setCompressedSize setCrc setExtra setMethod setSize setTime toString Методи, успадковані від класу java.lang.Object дорівнює finalize getClass notify notifyAll wait wait wait Примітка: Програми не працюватимуть в онлайн-IDE, оскільки вони не можуть читати файл Програма 1: Java
//Java program demonstrating JarEntry methodimportjava.io.FileInputStream;importjava.io.IOException;importjava.io.PrintStream;importjava.util.jar.JarEntry;importjava.util.jar.JarInputStream;classJarEntryDemo{publicstaticvoidmain(String[]args)throwsIOException{FileInputStreamfis=newFileInputStream('codechecker.jar');JarInputStreamjis=newJarInputStream(fis);JarEntryje=jis.getNextJarEntry();PrintStreamout=System.out;//illustrating getAttributesout.println(je.getAttributes());//illustrating getCodeSignerout.println(je.getCodeSigners());//illustrating getCertificatesout.println(je.getCertificates());}}
Програма 2: Java
//Java program demonstrating JarEntry methodpackagejava.util.jar;importjava.io.IOException;importjava.util.zip.ZipEntry;importjava.security.CodeSigner;importjava.security.cert.Certificate;publicclassJarEntryextendsZipEntry{Attributesattr;Certificate[]certs;CodeSigner[]signers;publicJarEntry(Stringname){super(name);}publicJarEntry(ZipEntryze){super(ze);}publicJarEntry(JarEntryje){this((ZipEntry)je);this.attr=je.attr;this.certs=je.certs;this.signers=je.signers;}publicAttributesgetAttributes()throwsIOException{returnattr;}publicCertificate[]getCertificates(){returncerts==null?null:(Certificate[])certs.clone();}publicCodeSigner[]getCodeSigners(){returnsigners==null?null:(CodeSigner[])signers.clone();}}