Deze klasse wordt gebruikt om een JAR-bestandsitem weer te geven. Constructeurs:
JarEntry(JarEntry eten) :
Creëert een nieuwe JarEntry met velden uit het opgegeven JarEntry-object.
JarEntry(Stringnaam):
Creëert een nieuwe JarEntry voor de opgegeven naam van het JAR-bestandsitem.
JarEntry(ZipEntry met):
Creëert een nieuwe JarEntry met velden uit het opgegeven ZipEntry-object. Methoden:
Kenmerken 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
Certificaat[] 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.
Methoden overgenomen van klasse java.util.zip.ZipEntry kloon getCommentaar getCompressieSize getCrc getExtra getMethod getName getSize getTime hashCode isDirectory setCommentaar setCompressieSize setCrc setExtra setMethod setSize setTime toString Methoden overgenomen van klasse java.lang.Object is gelijk aan voltooien getClass notificeren notificerenAll wachten wachten wachten Opmerking: de programma's kunnen niet worden uitgevoerd op online IDE omdat ze het bestand niet kunnen lezen Programma 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());}}
Programma 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();}}