本文整理汇总了Java中sun.net.www.MessageHeader.add方法的典型用法代码示例。如果您正苦于以下问题:Java MessageHeader.add方法的具体用法?Java MessageHeader.add怎么用?Java MessageHeader.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.net.www.MessageHeader
的用法示例。
在下文中一共展示了MessageHeader.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Manifest
import sun.net.www.MessageHeader; //导入方法依赖的package包/类
public Manifest(String[] files) throws IOException {
MessageHeader globals = new MessageHeader();
globals.add("Manifest-Version", VERSION);
String jdkVersion = System.getProperty("java.version");
globals.add("Created-By", "Manifest JDK "+jdkVersion);
addEntry(globals);
addFiles(null, files);
}
示例2: addFile
import sun.net.www.MessageHeader; //导入方法依赖的package包/类
public void addFile(File f) throws IOException {
String stdName = localToStd(f.getPath());
if (tableEntries.get(stdName) == null) {
MessageHeader mh = new MessageHeader();
mh.add("Name", stdName);
addEntry(mh);
}
}
示例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);
}
}