本文整理汇总了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());
}
}
示例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);
}
}
示例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);
}
}