當前位置: 首頁>>代碼示例>>Java>>正文


Java JarInputStream.available方法代碼示例

本文整理匯總了Java中java.util.jar.JarInputStream.available方法的典型用法代碼示例。如果您正苦於以下問題:Java JarInputStream.available方法的具體用法?Java JarInputStream.available怎麽用?Java JarInputStream.available使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.jar.JarInputStream的用法示例。


在下文中一共展示了JarInputStream.available方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findBundleClassPathMatchingJarEntries

import java.util.jar.JarInputStream; //導入方法依賴的package包/類
/**
 * Checks the jar entries from the Bundle-Classpath for the given pattern.
 * 
 * @param list
 * @param ur
 */
private void findBundleClassPathMatchingJarEntries(List<String> list, URL url, String pattern) throws IOException {
	// get the stream to the resource and read it as a jar
	JarInputStream jis = new JarInputStream(url.openStream());
	Set<String> result = new LinkedHashSet<String>(8);

	boolean patternWithFolderSlash = pattern.startsWith(FOLDER_SEPARATOR);

	// parse the jar and do pattern matching
	try {
		while (jis.available() > 0) {
			JarEntry jarEntry = jis.getNextJarEntry();
			// if the jar has ended, the entry can be null (on Sun JDK at least)
			if (jarEntry != null) {
				String entryPath = jarEntry.getName();

				// check if leading "/" is needed or not (it depends how the jar was created)
				if (entryPath.startsWith(FOLDER_SEPARATOR)) {
					if (!patternWithFolderSlash) {
						entryPath = entryPath.substring(FOLDER_SEPARATOR.length());
					}
				} else {
					if (patternWithFolderSlash) {
						entryPath = FOLDER_SEPARATOR.concat(entryPath);
					}
				}
				if (getPathMatcher().match(pattern, entryPath)) {
					result.add(entryPath);
				}
			}
		}
	} finally {
		try {
			jis.close();
		} catch (IOException io) {
			// ignore it - nothing we can't do about it
		}
	}

	if (logger.isTraceEnabled())
		logger.trace("Found in nested jar [" + url + "] matching entries " + result);

	list.addAll(result);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:50,代碼來源:OsgiBundleResourcePatternResolver.java


注:本文中的java.util.jar.JarInputStream.available方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。