本文整理汇总了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);
}
}
示例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();
}
示例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();
}