Java Code Examples for java.util.jar.JarInputStream#getManifest()
The following examples show how to use
java.util.jar.JarInputStream#getManifest() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException { if (in.getManifest() != null) { ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(me); in.getManifest().write(out); out.closeEntry(); } byte[] buffer = new byte[1 << 14]; for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { out.putNextEntry(je); for (int nr; 0 < (nr = in.read(buffer)); ) { out.write(buffer, 0, nr); } } in.close(); markJarFile(out); // add PACK200 comment }
Example 2
Source File: Utils.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException { if (in.getManifest() != null) { ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(me); in.getManifest().write(out); out.closeEntry(); } byte[] buffer = new byte[1 << 14]; for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { out.putNextEntry(je); for (int nr; 0 < (nr = in.read(buffer)); ) { out.write(buffer, 0, nr); } } in.close(); markJarFile(out); // add PACK200 comment }
Example 3
Source File: Utils.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException { if (in.getManifest() != null) { ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(me); in.getManifest().write(out); out.closeEntry(); } byte[] buffer = new byte[1 << 14]; for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { out.putNextEntry(je); for (int nr; 0 < (nr = in.read(buffer)); ) { out.write(buffer, 0, nr); } } in.close(); markJarFile(out); // add PACK200 comment }
Example 4
Source File: Utils.java From hottub with GNU General Public License v2.0 | 6 votes |
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException { if (in.getManifest() != null) { ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(me); in.getManifest().write(out); out.closeEntry(); } byte[] buffer = new byte[1 << 14]; for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { out.putNextEntry(je); for (int nr; 0 < (nr = in.read(buffer)); ) { out.write(buffer, 0, nr); } } in.close(); markJarFile(out); // add PACK200 comment }
Example 5
Source File: Utils.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException { if (in.getManifest() != null) { ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(me); in.getManifest().write(out); out.closeEntry(); } byte[] buffer = new byte[1 << 14]; for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { out.putNextEntry(je); for (int nr; 0 < (nr = in.read(buffer)); ) { out.write(buffer, 0, nr); } } in.close(); markJarFile(out); // add PACK200 comment }
Example 6
Source File: Utils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException { if (in.getManifest() != null) { ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(me); in.getManifest().write(out); out.closeEntry(); } byte[] buffer = new byte[1 << 14]; for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { out.putNextEntry(je); for (int nr; 0 < (nr = in.read(buffer)); ) { out.write(buffer, 0, nr); } } in.close(); markJarFile(out); // add PACK200 comment }
Example 7
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException { if (in.getManifest() != null) { ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(me); in.getManifest().write(out); out.closeEntry(); } byte[] buffer = new byte[1 << 14]; for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { out.putNextEntry(je); for (int nr; 0 < (nr = in.read(buffer)); ) { out.write(buffer, 0, nr); } } in.close(); markJarFile(out); // add PACK200 comment }
Example 8
Source File: Utils.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException { if (in.getManifest() != null) { ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(me); in.getManifest().write(out); out.closeEntry(); } byte[] buffer = new byte[1 << 14]; for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { out.putNextEntry(je); for (int nr; 0 < (nr = in.read(buffer)); ) { out.write(buffer, 0, nr); } } in.close(); markJarFile(out); // add PACK200 comment }
Example 9
Source File: JarResourceLocation.java From elasticsearch-gatherer with Apache License 2.0 | 5 votes |
public Manifest getManifest() throws IOException { if (jarFile != null) { return jarFile.getManifest(); } else { try { JarInputStream is = new JarInputStream(new ByteArrayInputStream(this.content)); return is.getManifest(); } catch (IOException e) { } } return null; }
Example 10
Source File: PluginEngineTargetForJarFileTest.java From byte-buddy with Apache License 2.0 | 5 votes |
@Test public void testManifest() throws Exception { Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); Plugin.Engine.Target target = new Plugin.Engine.Target.ForJarFile(file); target.write(manifest).close(); JarInputStream inputStream = new JarInputStream(new FileInputStream(file)); try { Manifest readManifest = inputStream.getManifest(); assertThat(readManifest.getMainAttributes().get(Attributes.Name.MANIFEST_VERSION), is((Object) "1.0")); assertThat(inputStream.getNextJarEntry(), nullValue(JarEntry.class)); } finally { inputStream.close(); } }
Example 11
Source File: Utilities.java From AVM with MIT License | 5 votes |
public static String extractMainClassName(JarInputStream jarReader, NameStyle nameStyle) { Manifest manifest = jarReader.getManifest(); if (null != manifest && manifest.getMainAttributes() != null) { String mainClassName = manifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (nameStyle.equals(NameStyle.SLASH_NAME)) { mainClassName = Utilities.fulllyQualifiedNameToInternalName(mainClassName); } return mainClassName; } else { throw new RuntimeException("Manifest file required"); } }
Example 12
Source File: Archive.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Create an Archive based on contents of an InputStream, get file object for * the stream and use it. Native code is not allowed. * * @param is Jar file data in an InputStream. */ @SuppressWarnings("resource") // The input stream, is, must not be closed here. Archive(BundleArchiveImpl ba, InputStream is) throws IOException { this.ba = ba; path = "."; final JarInputStream ji = new JarInputStream(is); manifest = ji.getManifest(); if (manifest == null) { throw new IOException("Bundle manifest is missing"); } content = loadJarStream(ji); }
Example 13
Source File: JarUtil.java From uavstack with Apache License 2.0 | 5 votes |
/** * 提取jar包的Manifest * * @param jarFilePath * @return */ public static Manifest getJarManifest(String jarFilePath) { try { @SuppressWarnings("resource") JarInputStream jis = new JarInputStream(new FileInputStream(jarFilePath)); return jis.getManifest(); } catch (IOException e) { // ignore } return null; }
Example 14
Source File: PackerImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
void run(JarInputStream in, OutputStream out) throws IOException { // First thing we do is get the manifest, as JIS does // not provide the Manifest as an entry. if (in.getManifest() != null) { ByteArrayOutputStream tmp = new ByteArrayOutputStream(); in.getManifest().write(tmp); InputStream tmpIn = new ByteArrayInputStream(tmp.toByteArray()); pkg.addFile(readFile(JarFile.MANIFEST_NAME, tmpIn)); } for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { InFile inFile = new InFile(je); String name = inFile.name; Package.File bits = readFile(name, in); Package.File file = null; // (5078608) : discount the resource files in META-INF // from segment computation. long inflen = (isMetaInfFile(name)) ? 0L : inFile.getInputLength(); if ((segmentSize += inflen) > segmentLimit) { segmentSize -= inflen; int nextCount = -1; // don't know; it's a stream flushPartial(out, nextCount); } if (verbose > 1) { Utils.log.fine("Reading " + name); } assert(je.isDirectory() == name.endsWith("/")); if (isClassFile(name)) { file = readClass(name, bits.getInputStream()); } if (file == null) { file = bits; pkg.addFile(file); } inFile.copyTo(file); noteRead(inFile); } flushAll(out); }
Example 15
Source File: PackerImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
void run(JarInputStream in, OutputStream out) throws IOException { // First thing we do is get the manifest, as JIS does // not provide the Manifest as an entry. if (in.getManifest() != null) { ByteArrayOutputStream tmp = new ByteArrayOutputStream(); in.getManifest().write(tmp); InputStream tmpIn = new ByteArrayInputStream(tmp.toByteArray()); pkg.addFile(readFile(JarFile.MANIFEST_NAME, tmpIn)); } for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { InFile inFile = new InFile(je); String name = inFile.name; Package.File bits = readFile(name, in); Package.File file = null; // (5078608) : discount the resource files in META-INF // from segment computation. long inflen = (isMetaInfFile(name)) ? 0L : inFile.getInputLength(); if ((segmentSize += inflen) > segmentLimit) { segmentSize -= inflen; int nextCount = -1; // don't know; it's a stream flushPartial(out, nextCount); } if (verbose > 1) { Utils.log.fine("Reading " + name); } assert(je.isDirectory() == name.endsWith("/")); if (isClassFile(name)) { file = readClass(name, bits.getInputStream()); } if (file == null) { file = bits; pkg.addFile(file); } inFile.copyTo(file); noteRead(inFile); } flushAll(out); }
Example 16
Source File: PackerImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
void run(JarInputStream in, OutputStream out) throws IOException { // First thing we do is get the manifest, as JIS does // not provide the Manifest as an entry. if (in.getManifest() != null) { ByteArrayOutputStream tmp = new ByteArrayOutputStream(); in.getManifest().write(tmp); InputStream tmpIn = new ByteArrayInputStream(tmp.toByteArray()); pkg.addFile(readFile(JarFile.MANIFEST_NAME, tmpIn)); } for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { InFile inFile = new InFile(je); String name = inFile.name; Package.File bits = readFile(name, in); Package.File file = null; // (5078608) : discount the resource files in META-INF // from segment computation. long inflen = (isMetaInfFile(name)) ? 0L : inFile.getInputLength(); if ((segmentSize += inflen) > segmentLimit) { segmentSize -= inflen; int nextCount = -1; // don't know; it's a stream flushPartial(out, nextCount); } if (verbose > 1) { Utils.log.fine("Reading " + name); } assert(je.isDirectory() == name.endsWith("/")); if (isClassFile(name)) { file = readClass(name, bits.getInputStream()); } if (file == null) { file = bits; pkg.addFile(file); } inFile.copyTo(file); noteRead(inFile); } flushAll(out); }
Example 17
Source File: PackerImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
void run(JarInputStream in, OutputStream out) throws IOException { // First thing we do is get the manifest, as JIS does // not provide the Manifest as an entry. if (in.getManifest() != null) { ByteArrayOutputStream tmp = new ByteArrayOutputStream(); in.getManifest().write(tmp); InputStream tmpIn = new ByteArrayInputStream(tmp.toByteArray()); pkg.addFile(readFile(JarFile.MANIFEST_NAME, tmpIn)); } for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { InFile inFile = new InFile(je); String name = inFile.name; Package.File bits = readFile(name, in); Package.File file = null; // (5078608) : discount the resource files in META-INF // from segment computation. long inflen = (isMetaInfFile(name)) ? 0L : inFile.getInputLength(); if ((segmentSize += inflen) > segmentLimit) { segmentSize -= inflen; int nextCount = -1; // don't know; it's a stream flushPartial(out, nextCount); } if (verbose > 1) { Utils.log.fine("Reading " + name); } assert(je.isDirectory() == name.endsWith("/")); if (isClassFile(name)) { file = readClass(name, bits.getInputStream()); } if (file == null) { file = bits; pkg.addFile(file); } inFile.copyTo(file); noteRead(inFile); } flushAll(out); }
Example 18
Source File: PackerImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
void run(JarInputStream in, OutputStream out) throws IOException { // First thing we do is get the manifest, as JIS does // not provide the Manifest as an entry. if (in.getManifest() != null) { ByteArrayOutputStream tmp = new ByteArrayOutputStream(); in.getManifest().write(tmp); InputStream tmpIn = new ByteArrayInputStream(tmp.toByteArray()); pkg.addFile(readFile(JarFile.MANIFEST_NAME, tmpIn)); } for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { InFile inFile = new InFile(je); String name = inFile.name; Package.File bits = readFile(name, in); Package.File file = null; // (5078608) : discount the resource files in META-INF // from segment computation. long inflen = (isMetaInfFile(name)) ? 0L : inFile.getInputLength(); if ((segmentSize += inflen) > segmentLimit) { segmentSize -= inflen; int nextCount = -1; // don't know; it's a stream flushPartial(out, nextCount); } if (verbose > 1) { Utils.log.fine("Reading " + name); } assert(je.isDirectory() == name.endsWith("/")); if (isClassFile(name)) { file = readClass(name, bits.getInputStream()); } if (file == null) { file = bits; pkg.addFile(file); } inFile.copyTo(file); noteRead(inFile); } flushAll(out); }
Example 19
Source File: PackerImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
void run(JarInputStream in, OutputStream out) throws IOException { // First thing we do is get the manifest, as JIS does // not provide the Manifest as an entry. if (in.getManifest() != null) { ByteArrayOutputStream tmp = new ByteArrayOutputStream(); in.getManifest().write(tmp); InputStream tmpIn = new ByteArrayInputStream(tmp.toByteArray()); pkg.addFile(readFile(JarFile.MANIFEST_NAME, tmpIn)); } for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { InFile inFile = new InFile(je); String name = inFile.name; Package.File bits = readFile(name, in); Package.File file = null; // (5078608) : discount the resource files in META-INF // from segment computation. long inflen = (isMetaInfFile(name)) ? 0L : inFile.getInputLength(); if ((segmentSize += inflen) > segmentLimit) { segmentSize -= inflen; int nextCount = -1; // don't know; it's a stream flushPartial(out, nextCount); } if (verbose > 1) { Utils.log.fine("Reading " + name); } assert(je.isDirectory() == name.endsWith("/")); if (isClassFile(name)) { file = readClass(name, bits.getInputStream()); } if (file == null) { file = bits; pkg.addFile(file); } inFile.copyTo(file); noteRead(inFile); } flushAll(out); }
Example 20
Source File: PackerImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
void run(JarInputStream in, OutputStream out) throws IOException { // First thing we do is get the manifest, as JIS does // not provide the Manifest as an entry. if (in.getManifest() != null) { ByteArrayOutputStream tmp = new ByteArrayOutputStream(); in.getManifest().write(tmp); InputStream tmpIn = new ByteArrayInputStream(tmp.toByteArray()); pkg.addFile(readFile(JarFile.MANIFEST_NAME, tmpIn)); } for (JarEntry je; (je = in.getNextJarEntry()) != null; ) { InFile inFile = new InFile(je); String name = inFile.name; Package.File bits = readFile(name, in); Package.File file = null; // (5078608) : discount the resource files in META-INF // from segment computation. long inflen = (isMetaInfFile(name)) ? 0L : inFile.getInputLength(); if ((segmentSize += inflen) > segmentLimit) { segmentSize -= inflen; int nextCount = -1; // don't know; it's a stream flushPartial(out, nextCount); } if (verbose > 1) { Utils.log.fine("Reading " + name); } assert(je.isDirectory() == name.endsWith("/")); if (isClassFile(name)) { file = readClass(name, bits.getInputStream()); } if (file == null) { file = bits; pkg.addFile(file); } inFile.copyTo(file); noteRead(inFile); } flushAll(out); }