zoukankan      html  css  js  c++  java
  • JAR API

    JAR API包括使用 manifest 文件的类。Manifest类的一个对象表示一个manifest文件。 在代码中创建一个Manifest对象,如下所示:

    1
    Manifest manifest = new Manifest();

    可以从manifest文件中读取条目并向其写入条目。要将一个条目添加到主部分,使用Manifest类中的getMainAttributes()方法获取Attributes类的实例,并使用其put()方法继续向其添加名称/值对。

    以下代码将一些属性添加到manifest对象的主部分。已知的属性名称在Attributes.Name类中定义为常量。

    例如,常量Attributes.Name.MANIFEST_VERSION表示manifest版本属性名称。

    1
    2
    3
    4
    5
    Manifest manifest = new Manifest();
    Attributes  mainAttribs = manifest.getMainAttributes(); 
    mainAttribs.put(Attributes.Name.MANIFEST_VERSION, "1.0"); 
    mainAttribs.put(Attributes.Name.MAIN_CLASS, "cn.sxt.Main");
     mainAttribs.put(Attributes.Name.SEALED, "true");

    将单个条目添加到manifest文件比添加到主条目稍微复杂一点。以下代码显示如何向Manifest对象添加单个条目:

    1
    2
    3
    4
    5
    Map<String,Attributes> attribsMap = manifest.getEntries();
    Attributes attribs  = new Attributes();
    Attributes.Name name = new Attributes.Name("Sealed");
    attribs.put(name, "false");
    attribsMap.put("cn/sxt/archives/", attribs);

    要将manifest文件添加到JAR文件,请在JarOutputStream类的一个构造函数中指定它。例如,以下代码创建一个jar输出流,以使用Manifest对象创建一个test.jar文件:

    点击链接查看详细内容

  • 相关阅读:
    CCI_Q1.5
    CCI_Q1.4
    js 记录一次日期转换
    列表注册自定义鼠标右键事件
    jquery点击页面其他位置隐藏div
    C#一句话判断两个List<T>是否相等
    使用Js进行linq处理
    记录一次DataTable排序的问题
    JavaScript模板引擎Handlebars
    Redis学习笔记
  • 原文地址:https://www.cnblogs.com/hane/p/7306513.html
Copyright © 2011-2022 走看看