Ta klasa służy do reprezentowania wpisu w pliku JAR. Konstruktorzy:
JarEntry(JarEntry je) :
Tworzy nowy obiekt JarEntry z polami pobranymi z określonego obiektu JarEntry.
JarEntry(nazwa ciągu):
Tworzy nowy wpis JarEntry dla określonej nazwy wpisu pliku JAR.
JarEntry(ZipEntry ze) :
Tworzy nowy obiekt JarEntry z polami pobranymi z określonego obiektu ZipEntry. Metody:
Atrybuty 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
Certyfikat[] 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.
Metody dziedziczone z klasy java.util.zip.ZipEntry klon getKomentarz getCompressedSize getCrc getExtra getMetoda getName getSize getTime hashCode isDirectory setKomentarz ustawionyCompressedSize setCrc setExtra setMetoda ustawionaSize setTime toString Metody dziedziczone z klasy java.lang.Object równa się sfinalizuj getClass powiadom powiadomienieWszystkie czekaj czekaj czekaj Uwaga: programy nie będą działać w trybie online IDE, ponieważ nie są w stanie odczytać pliku Program 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());}}
Program 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();}}