當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。