当前位置: 首页>>代码示例>>Java>>正文


Java MessageHeader.print方法代码示例

本文整理汇总了Java中sun.net.www.MessageHeader.print方法的典型用法代码示例。如果您正苦于以下问题:Java MessageHeader.print方法的具体用法?Java MessageHeader.print怎么用?Java MessageHeader.print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.net.www.MessageHeader的用法示例。


在下文中一共展示了MessageHeader.print方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeEntry

import sun.net.www.MessageHeader; //导入方法依赖的package包/类
/**
 * Given a manifest entry, computes the signature entry for this
 * manifest entry.
 */
private MessageHeader computeEntry(MessageHeader mh) throws IOException {
    MessageHeader smh = new MessageHeader();

    String name = mh.findValue("Name");
    if (name == null) {
        return null;
    }
    smh.set("Name", name);

    try {
        for (int i = 0; i < hashes.length; ++i) {
            MessageDigest dig = getDigest(hashes[i]);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintStream ps = new PrintStream(baos);
            mh.print(ps);
            byte[] headerBytes = baos.toByteArray();
            byte[] digest = dig.digest(headerBytes);
            smh.set(hashes[i] + "-Digest", Base64.getMimeEncoder().encodeToString(digest));
        }
        return smh;
    } catch (NoSuchAlgorithmException e) {
        throw new JarException(e.getMessage());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:SignatureFile.java

示例2: stream

import sun.net.www.MessageHeader; //导入方法依赖的package包/类
/**
 * Add a signature file at current position in a stream
 */
public void stream(OutputStream os) throws IOException {

    /* the first header in the file should be the global one.
     * It should say "SignatureFile-Version: x.x"; barf if not
     */
    MessageHeader globals = entries.elementAt(0);
    if (globals.findValue("Signature-Version") == null) {
        throw new JarException("Signature file requires " +
                        "Signature-Version: 1.0 in 1st header");
    }

    PrintStream ps = new PrintStream(os);
    globals.print(ps);

    for (int i = 1; i < entries.size(); ++i) {
        MessageHeader mh = entries.elementAt(i);
        mh.print(ps);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:SignatureFile.java

示例3: stream

import sun.net.www.MessageHeader; //导入方法依赖的package包/类
public void stream(OutputStream os) throws IOException {

        PrintStream ps;
        if (os instanceof PrintStream) {
            ps = (PrintStream) os;
        } else {
            ps = new PrintStream(os);
        }

        /* the first header in the file should be the global one.
         * It should say "Manifest-Version: x.x"; if not add it
         */
        MessageHeader globals = entries.elementAt(0);

        if (globals.findValue("Manifest-Version") == null) {
            /* Assume this is a user-defined manifest.  If it has a Name: <..>
             * field, then it is not global, in which case we just add our own
             * global Manifest-version: <version>
             * If the first MessageHeader has no Name: <..>, we assume it
             * is a global header and so prepend Manifest to it.
             */
            String jdkVersion = System.getProperty("java.version");

            if (globals.findValue("Name") == null) {
                globals.prepend("Manifest-Version", VERSION);
                globals.add("Created-By", "Manifest JDK "+jdkVersion);
            } else {
                ps.print("Manifest-Version: "+VERSION+"\r\n"+
                         "Created-By: "+jdkVersion+"\r\n\r\n");
            }
            ps.flush();
        }

        globals.print(ps);

        for (int i = 1; i < entries.size(); ++i) {
            MessageHeader mh = entries.elementAt(i);
            mh.print(ps);
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:Manifest.java


注:本文中的sun.net.www.MessageHeader.print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。