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