JAVAutil。罐子Java中的JarEntry类

此类用于表示JAR文件条目。 施工人员:

null
  • Jarrentry(Jarrentry je): 创建一个新的JarEntry,其中的字段取自指定的JarEntry对象。
  • JarEntry(字符串名称): 为指定的JAR文件条目名创建新的JAR条目。
  • Jarrentry(ZipEntry ze): 创建一个新的JarEntry,其中的字段取自指定的ZipEntry对象。

方法:

  • 属性getAttributes(): 返回此项的清单属性,如果没有,则返回null。
    Syntax :public Attributes getAttributes()
                             throws IOException
    Returns:
    the Manifest Attributes for this entry, or null if none
  • 证书[]获取证书(): 返回此项的证书对象,如果没有,则返回null。
    Syntax :public Certificate[] getCertificates()
    Returns:
    the Certificate objects for this entry, or null if none.
  • CodeSigner[]getCodeSigners(): 返回此项的CodeSigner对象,如果没有,则返回null。
    Syntax :public CodeSigner[] getCodeSigners()
    Returns:
    the CodeSigner objects for this entry, or null if none.

从java类继承的方法。util。拉链齐彭特里 克隆,getComment,getCompressedSize,getCrc,getExtra,getMethod,getName,getSize,getTime,hashCode,isDirectory,setComment,setCompressedSize,setCrc,setExtra,setMethod,setSize,setTime,toString 从java类继承的方法。lang.反对 equals,finalize,getClass,notify,notifyAll,wait,wait,wait

注意:这些程序不能在在线IDE上运行,因为它们不能读取文件 项目1:

//Java program demonstrating JarEntry method
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
class JarEntryDemo
{
public static void main(String[] args) throws IOException
{
FileInputStream fis = new FileInputStream( "codechecker.jar" );
JarInputStream jis = new JarInputStream(fis);
JarEntry je=jis.getNextJarEntry();
PrintStream out = System.out;
//illustrating getAttributes
out.println(je.getAttributes());
//illustrating getCodeSigner
out.println(je.getCodeSigners());
//illustrating getCertificates
out.println(je.getCertificates());
}
}


项目2:

//Java program demonstrating JarEntry method
package java.util.jar;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.security.CodeSigner;
import java.security.cert.Certificate;
public class JarEntry extends ZipEntry
{
Attributes attr;
Certificate[] certs;
CodeSigner[] signers;
public JarEntry(String name)
{
super (name);
}
public JarEntry(ZipEntry ze)
{
super (ze);
}
public JarEntry(JarEntry je)
{
this ((ZipEntry)je);
this .attr = je.attr;
this .certs = je.certs;
this .signers = je.signers;
}
public Attributes getAttributes() throws IOException
{
return attr;
}
public Certificate[] getCertificates()
{
return certs == null ? null : (Certificate[]) certs.clone();
}
public CodeSigner[] getCodeSigners()
{
return signers == null ? null : (CodeSigner[]) signers.clone();
}
}


本文由 尼森特·夏尔马 .如果你喜欢GeekSforgek,并想贡献自己的力量,你也可以使用 贡献极客。组织 或者把你的文章寄到contribute@geeksforgeeks.org.看到你的文章出现在Geeksforgeks主页上,并帮助其他极客。

如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享