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


Java JarInputStream.closeEntry方法代码示例

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


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

示例1: setupEntryCertificates

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
void setupEntryCertificates(JarEntry entry) {
	// Fallback to JarInputStream to obtain certificates, not fast but hopefully not
	// happening that often.
	try {
		JarInputStream inputStream = new JarInputStream(
				getData().getInputStream(ResourceAccess.ONCE));
		try {
			java.util.jar.JarEntry certEntry = inputStream.getNextJarEntry();
			while (certEntry != null) {
				inputStream.closeEntry();
				if (entry.getName().equals(certEntry.getName())) {
					setCertificates(entry, certEntry);
				}
				setCertificates(getJarEntry(certEntry.getName()), certEntry);
				certEntry = inputStream.getNextJarEntry();
			}
		}
		finally {
			inputStream.close();
		}
	}
	catch (IOException ex) {
		throw new IllegalStateException(ex);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:JarFile.java

示例2: extract

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
/**Find the jar I was loaded from and extract all entries except my own
  * class file.
  *@throws Exception if anything doesn't work, punt
  */
 public void extract() throws Exception {
   URL jarURL =
     this.getClass().getProtectionDomain().getCodeSource().getLocation();

   InputStream is = jarURL.openStream();
   JarInputStream jis = new JarInputStream( is);
   
   Manifest mf = null;

   for ( JarEntry je;; ) {
     je = jis.getNextJarEntry();
     if ( je == null )
     	break;
     if ( null == mf ) {
       mf = jis.getManifest();
if ( null != mf )
  setDefaults( mf.getMainAttributes());
     }
     if ( ! je.getName().equals( me) )
extract( je, jis);
     jis.closeEntry();
   }
   
   jis.close();
 }
 
开发者ID:greenplum-db,项目名称:pljava,代码行数:30,代码来源:JarX.java

示例3: JarLoader

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
/**
 * Creates a loader to load a specified JAR file.
 *
 * We place no restrictions on what the <code>URL</code> points to here.
 * instead any access restrictions (from trusted java) are enforced by
 * the <code>Security Manager</code> defined in <code>Backend.java</code>.
 *
 * @param url : The URL to load
 * @return JarLoader : Classloader for a specified JAR
 * @throws IOException : when the Jar cannot be read
 *
 */
JarLoader(ClassLoader parent, URL url) throws IOException
{
	super(parent);

	m_url = url;
	m_entries = new HashMap();
	m_images  = new HashMap();

	// Just having a JAR in your CLASSPATH will cause us to load it,
	// which means you need security access to it.
	JarInputStream jis = new JarInputStream(url.openStream());
	ByteArrayOutputStream img = new ByteArrayOutputStream();
	byte[] buf = new byte[1024];
	JarEntry je;
	for (je = jis.getNextJarEntry();
		 je != null;
		 je = jis.getNextJarEntry())
	{
		if (je.isDirectory())
			continue;
		String entryName = je.getName();
		Attributes attr = je.getAttributes();
		int nBytes;

		img.reset();
		while ((nBytes = jis.read(buf)) > 0)
			img.write(buf, 0, nBytes);
		jis.closeEntry();

		m_entries.put(entryName, img.toByteArray());
	}
	m_manifest = jis.getManifest();
}
 
开发者ID:greenplum-db,项目名称:pljava,代码行数:46,代码来源:JarLoader.java


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