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