Java Reference
In-Depth Information
byte[] buffer = new byte[1024];
int count = -1;
while ((count = bis.read(buffer)) != -1) {
jos.write(buffer, 0, count);
}
bis.close();
}
public static Manifest getManifest() {
Manifest manifest = new Manifest();
/* Add main attributes
1. Manifest Version
2. Main-Class
3. Sealed
*/
Attributes mainAttribs = manifest.getMainAttributes();
mainAttribs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
mainAttribs.put(Attributes.Name.MAIN_CLASS, "com.jdojo.archives.Test");
mainAttribs.put(Attributes.Name.SEALED, "true");
/* Add two individual sections */
/* Do not seal the com/jdojo/archives/ package. Note that you
have sealed the whole JAR file and to exclude this package
you we must add a Sealed: false attribute for this package
separately.
*/
Map<String, Attributes> attribsMap = manifest.getEntries();
// Create an attribute "Sealed : false" and
// add it for individual entry "Name: com/jdojo/archives/"
Attributes a1 = getAttribute("Sealed", "false");
attribsMap.put("com/jdojo/archives/", a1);
// Create an attribute "Content-Type: image/bmp" and
// add it for images/logo.bmp
Attributes a2 = getAttribute("Content-Type", "image/bmp");
attribsMap.put("images/logo.bmp", a2);
return manifest;
}
public static Attributes getAttribute(String name, String value) {
Attributes a = new Attributes();
Attributes.Name attribName = new Attributes.Name(name);
a.put(attribName, value);
return a;
}
}
Search WWH ::




Custom Search