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


Java JarFile.getEntry方法代码示例

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


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

示例1: findCurrVer

import java.util.jar.JarFile; //导入方法依赖的package包/类
private static String findCurrVer(JarFile jar, String infix) throws IOException {
    // first try to find the Bundle for 5.0+ (after openide split)
    ZipEntry bundle = jar.getEntry("org/netbeans/core/startup/Bundle" + infix + ".properties"); // NOI18N
    if (bundle == null) {
        // might be <5.0 (before openide split)
        bundle = jar.getEntry("org/netbeans/core/Bundle" + infix + ".properties"); // NOI18N
    }
    if (bundle == null) {
        return null;
    }
    Properties props = new Properties();
    InputStream is = jar.getInputStream(bundle);
    try {
        props.load(is);
    } finally {
        is.close();
    }
    return props.getProperty("currentVersion"); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:NbPlatform.java

示例2: getInputStream

import java.util.jar.JarFile; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, JarFile jarFile, JspCompilationContext ctxt,
		ErrorDispatcher err) throws JasperException, IOException {

	InputStream in = null;

	if (jarFile != null) {
		String jarEntryName = fname.substring(1, fname.length());
		ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
		if (jarEntry == null) {
			throw new FileNotFoundException(Localizer.getMessage("jsp.error.file.not.found", fname));
		}
		in = jarFile.getInputStream(jarEntry);
	} else {
		in = ctxt.getResourceAsStream(fname);
	}

	if (in == null) {
		throw new FileNotFoundException(Localizer.getMessage("jsp.error.file.not.found", fname));
	}

	return in;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:JspUtil.java

示例3: updateRepo

import java.util.jar.JarFile; //导入方法依赖的package包/类
protected void updateRepo(RepoUpdater updater, String indexJarPath) throws UpdateException {
    File indexJar = TestUtils.copyResourceToTempFile(indexJarPath);
    try {
        if (updater instanceof IndexV1Updater) {
            JarFile jarFile = new JarFile(indexJar);
            JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1Updater.DATA_FILE_NAME);
            InputStream indexInputStream = jarFile.getInputStream(indexEntry);
            ((IndexV1Updater) updater).processIndexV1(indexInputStream, indexEntry, null);
        } else {
            updater.processDownloadedFile(indexJar);
        }
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    } finally {
        if (indexJar != null && indexJar.exists()) {
            indexJar.delete();
        }
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:21,代码来源:MultiRepoUpdaterTest.java

示例4: getInputStream

import java.util.jar.JarFile; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, JarFile jarFile,
                     JspCompilationContext ctxt,
                     ErrorDispatcher err)
    throws JasperException, IOException {

    InputStream in = null;

if (jarFile != null) {
    String jarEntryName = fname.substring(1, fname.length());
    ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
    if (jarEntry == null) {
    err.jspError("jsp.error.file.not.found", fname);
    }
    in = jarFile.getInputStream(jarEntry);
} else {
    in = ctxt.getResourceAsStream(fname);
}

if (in == null) {
    err.jspError("jsp.error.file.not.found", fname);
}

return in;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:JspUtil.java

示例5: getResourceFile

import java.util.jar.JarFile; //导入方法依赖的package包/类
/**
 * 获取 jar 包中的资源文件
 *
 * @param file     jar 包
 * @param resource 资源文件名
 * @return 读取流
 */
public InputStream getResourceFile(JarFile file, String resource) {
	try {

		ZipEntry entry = file.getEntry("resources/" + resource);
		if (entry == null) {
			entry = file.getEntry(resource);
			if (entry == null) {
				entry = file.getEntry("resource/" + resource);
				if (entry == null) {
					return null;
				}
			}
		}

		return file.getInputStream(entry);
	} catch (Exception e) {
		return null;
	}
}
 
开发者ID:Him188,项目名称:JPRE,代码行数:27,代码来源:PluginManager.java

示例6: getDescription

import java.util.jar.JarFile; //导入方法依赖的package包/类
/**
 * 获取 Jar 包内的插件信息 (PluginDescription)  [cq.json/plugin.json/jpre.json]
 * 本方法只会读取插件信息, 不会添加到插件信息列表中.
 * 若要添加到插件列表, 请使用 {@link #loadPluginDescription(String)}
 *
 * @param file 文件
 * @return PluginDescription
 */
public PluginDescription getDescription(JarFile file) {
	try {
		ZipEntry entry = file.getEntry("cq.json");
		if (entry == null) {
			entry = file.getEntry("plugin.json");
			if (entry == null) {
				entry = file.getEntry("jpre.json");
				if (entry == null) {
					return null;
				}
			}
		}

		return new Gson().fromJson(Utils.readFile(file.getInputStream(entry)), PluginDescription.class).setFileName(file.getName());
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:Him188,项目名称:JPRE,代码行数:28,代码来源:PluginManager.java

示例7: getInputStream

import java.util.jar.JarFile; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, JarFile jarFile,
        JspCompilationContext ctxt, ErrorDispatcher err)
        throws JasperException, IOException {

    InputStream in = null;

    if (jarFile != null) {
        String jarEntryName = fname.substring(1, fname.length());
        ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
        if (jarEntry == null) {
            throw new FileNotFoundException(Localizer.getMessage(
                    "jsp.error.file.not.found", fname));
        }
        in = jarFile.getInputStream(jarEntry);
    } else {
        in = ctxt.getResourceAsStream(fname);
    }

    if (in == null) {
        throw new FileNotFoundException(Localizer.getMessage(
                "jsp.error.file.not.found", fname));
    }

    return in;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:26,代码来源:JspUtil.java

示例8: resource

import java.util.jar.JarFile; //导入方法依赖的package包/类
@Override
public byte[] resource(String path) throws IOException {
    if (nonexistentResources.contains(path)) {
        return null;
    }
    JarFile jf;
    try {
        jf = getJarFile(path);
    } catch (ZipException ex) {
        if (warnedFiles.add(file)) {
            LOGGER.log(Level.INFO, "Cannot open " + file, ex);
            dumpFiles(file, -1);
        }
        return null;
    }
    try {
        ZipEntry ze = jf.getEntry(path);
        if (ze == null) {
            nonexistentResources.add(path);
            return null;
        }

        if (LOGGER.isLoggable(Level.FINER)) {
            LOGGER.log(Level.FINER, "Loading {0} from {1}", new Object[] {path, file.getPath()});
        }
    
        int len = (int)ze.getSize();
        byte[] data = new byte[len];
        InputStream is = jf.getInputStream(ze);
        int count = 0;
        while (count < len) {
            count += is.read(data, count, len-count);
        }
        return data;
    } finally {
        releaseJarFile();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:JarClassLoader.java

示例9: addBundlesFromJar

import java.util.jar.JarFile; //导入方法依赖的package包/类
private static void addBundlesFromJar(JarFile jf, List<InputStream> bundleISs, String locBundleResource) throws IOException {
    for (String resource : getPossibleResources(locBundleResource)) {
        ZipEntry entry = jf.getEntry(resource);
        if (entry != null) {
            InputStream bundleIS = jf.getInputStream(entry);
            bundleISs.add(bundleIS);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ApisupportAntUtils.java

示例10: jarEntryExists

import java.util.jar.JarFile; //导入方法依赖的package包/类
public static boolean jarEntryExists(
        final File file,
        final String entry) throws IOException {
    JarFile jar = new JarFile(file);
    
    try {
        return jar.getEntry(entry) != null;
    } finally {
        jar.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FileUtils.java

示例11: processDownloadedFile

import java.util.jar.JarFile; //导入方法依赖的package包/类
public void processDownloadedFile(File downloadedFile) throws UpdateException {
    InputStream indexInputStream = null;
    try {
        if (downloadedFile == null || !downloadedFile.exists()) {
            throw new UpdateException(repo, downloadedFile + " does not exist!");
        }

        // Due to a bug in Android 5.0 Lollipop, the inclusion of spongycastle causes
        // breakage when verifying the signature of the downloaded .jar. For more
        // details, check out https://gitlab.com/fdroid/fdroidclient/issues/111.
        FDroidApp.disableSpongyCastleOnLollipop();

        JarFile jarFile = new JarFile(downloadedFile, true);
        JarEntry indexEntry = (JarEntry) jarFile.getEntry("index.xml");
        indexInputStream = new ProgressBufferedInputStream(jarFile.getInputStream(indexEntry),
                processIndexListener, new URL(repo.address), (int) indexEntry.getSize());

        // Process the index...
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);
        final SAXParser parser = factory.newSAXParser();
        final XMLReader reader = parser.getXMLReader();
        final RepoXMLHandler repoXMLHandler = new RepoXMLHandler(repo, createIndexReceiver());
        reader.setContentHandler(repoXMLHandler);
        reader.parse(new InputSource(indexInputStream));

        long timestamp = repoDetailsToSave.getAsLong(RepoTable.Cols.TIMESTAMP);
        if (timestamp < repo.timestamp) {
            throw new UpdateException(repo, "index.jar is older that current index! "
                    + timestamp + " < " + repo.timestamp);
        }

        signingCertFromJar = getSigningCertFromJar(indexEntry);

        // JarEntry can only read certificates after the file represented by that JarEntry
        // has been read completely, so verification cannot run until now...
        assertSigningCertFromXmlCorrect();
        commitToDb();
    } catch (SAXException | ParserConfigurationException | IOException e) {
        throw new UpdateException(repo, "Error parsing index", e);
    } finally {
        FDroidApp.enableSpongyCastleOnLollipop();
        Utils.closeQuietly(indexInputStream);
        if (downloadedFile != null) {
            if (!downloadedFile.delete()) {
                Log.w(TAG, "Couldn't delete file: " + downloadedFile.getAbsolutePath());
            }
        }
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:51,代码来源:RepoUpdater.java

示例12: processDownloadedIndex

import java.util.jar.JarFile; //导入方法依赖的package包/类
private void processDownloadedIndex(File outputFile, String cacheTag)
        throws IOException, RepoUpdater.UpdateException {
    JarFile jarFile = new JarFile(outputFile, true);
    JarEntry indexEntry = (JarEntry) jarFile.getEntry(DATA_FILE_NAME);
    InputStream indexInputStream = new ProgressBufferedInputStream(jarFile.getInputStream(indexEntry),
            processIndexListener, new URL(repo.address), (int) indexEntry.getSize());
    processIndexV1(indexInputStream, indexEntry, cacheTag);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:9,代码来源:IndexV1Updater.java

示例13: testIndexV1WithWrongCert

import java.util.jar.JarFile; //导入方法依赖的package包/类
@Test(expected = RepoUpdater.SigningException.class)
public void testIndexV1WithWrongCert() throws IOException, RepoUpdater.UpdateException {
    String badCert = "308202ed308201d5a003020102020426ffa009300d06092a864886f70d01010b05003027310b300906035504061302444531183016060355040a130f4e4f47415050532050726f6a656374301e170d3132313030363132303533325a170d3337303933303132303533325a3027310b300906035504061302444531183016060355040a130f4e4f47415050532050726f6a65637430820122300d06092a864886f70d01010105000382010f003082010a02820101009a8d2a5336b0eaaad89ce447828c7753b157459b79e3215dc962ca48f58c2cd7650df67d2dd7bda0880c682791f32b35c504e43e77b43c3e4e541f86e35a8293a54fb46e6b16af54d3a4eda458f1a7c8bc1b7479861ca7043337180e40079d9cdccb7e051ada9b6c88c9ec635541e2ebf0842521c3024c826f6fd6db6fd117c74e859d5af4db04448965ab5469b71ce719939a06ef30580f50febf96c474a7d265bb63f86a822ff7b643de6b76e966a18553c2858416cf3309dd24278374bdd82b4404ef6f7f122cec93859351fc6e5ea947e3ceb9d67374fe970e593e5cd05c905e1d24f5a5484f4aadef766e498adf64f7cf04bddd602ae8137b6eea40722d0203010001a321301f301d0603551d0e04160414110b7aa9ebc840b20399f69a431f4dba6ac42a64300d06092a864886f70d01010b0500038201010007c32ad893349cf86952fb5a49cfdc9b13f5e3c800aece77b2e7e0e9c83e34052f140f357ec7e6f4b432dc1ed542218a14835acd2df2deea7efd3fd5e8f1c34e1fb39ec6a427c6e6f4178b609b369040ac1f8844b789f3694dc640de06e44b247afed11637173f36f5886170fafd74954049858c6096308fc93c1bc4dd5685fa7a1f982a422f2a3b36baa8c9500474cf2af91c39cbec1bc898d10194d368aa5e91f1137ec115087c31962d8f76cd120d28c249cf76f4c70f5baa08c70a7234ce4123be080cee789477401965cfe537b924ef36747e8caca62dfefdd1a6288dcb1c4fd2aaa6131a7ad254e9742022cfd597d2ca5c660ce9e41ff537e5a4041e37"; // NOCHECKSTYLE LineLength
    Repo repo = MultiRepoUpdaterTest.createRepo("Testy", TESTY_JAR, context, badCert);
    IndexV1Updater updater = new IndexV1Updater(context, repo);
    JarFile jarFile = new JarFile(TestUtils.copyResourceToTempFile(TESTY_JAR), true);
    JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1Updater.DATA_FILE_NAME);
    InputStream indexInputStream = jarFile.getInputStream(indexEntry);
    updater.processIndexV1(indexInputStream, indexEntry, "fakeEtag");
    fail(); // it should never reach here, it should throw a SigningException
    getClass().getResourceAsStream("foo");
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:13,代码来源:IndexV1UpdaterTest.java

示例14: testIndexV1WithOldTimestamp

import java.util.jar.JarFile; //导入方法依赖的package包/类
@Test(expected = RepoUpdater.UpdateException.class)
public void testIndexV1WithOldTimestamp() throws IOException, RepoUpdater.UpdateException {
    Repo repo = MultiRepoUpdaterTest.createRepo("Testy", TESTY_JAR, context, TESTY_CERT);
    repo.timestamp = System.currentTimeMillis() / 1000;
    IndexV1Updater updater = new IndexV1Updater(context, repo);
    JarFile jarFile = new JarFile(TestUtils.copyResourceToTempFile(TESTY_JAR), true);
    JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1Updater.DATA_FILE_NAME);
    InputStream indexInputStream = jarFile.getInputStream(indexEntry);
    updater.processIndexV1(indexInputStream, indexEntry, "fakeEtag");
    fail(); // it should never reach here, it should throw a SigningException
    getClass().getResourceAsStream("foo");
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:13,代码来源:IndexV1UpdaterTest.java

示例15: addResourcesJar

import java.util.jar.JarFile; //导入方法依赖的package包/类
/**
 * Add a resources JAR. The contents of /META-INF/resources/ will be used if
 * a requested resource can not be found in the main context.
 */
public void addResourcesJar(URL url) {
    try {
        JarURLConnection conn = (JarURLConnection) url.openConnection();
        JarFile jarFile = conn.getJarFile();   
        ZipEntry entry = jarFile.getEntry("/");
        WARDirContext warDirContext = new WARDirContext(jarFile,
                new WARDirContext.Entry("/", entry));
        warDirContext.loadEntries();
        altDirContexts.add(warDirContext);
    } catch (IOException ioe) {
        log.warn(sm.getString("resources.addResourcesJarFail", url), ioe);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:BaseDirContext.java


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