本文整理匯總了Java中java.util.jar.JarFile.stream方法的典型用法代碼示例。如果您正苦於以下問題:Java JarFile.stream方法的具體用法?Java JarFile.stream怎麽用?Java JarFile.stream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.jar.JarFile
的用法示例。
在下文中一共展示了JarFile.stream方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testClosedJarFile
import java.util.jar.JarFile; //導入方法依賴的package包/類
@Test
public void testClosedJarFile() throws IOException {
JarFile jf = new JarFile(new File(System.getProperty("test.src", "."), "input.jar"));
jf.close();
try {
Stream s = jf.stream();
fail("Should have thrown IllegalStateException");
} catch (IllegalStateException e) {
// expected;
}
}
示例2: stream
import java.util.jar.JarFile; //導入方法依賴的package包/類
/**
* Returns a stream of versioned entries, derived from the base names of
* all entries in a multi-release {@code JarFile} that are present either in
* the base directory or in any versioned directory with a version number
* less than or equal to the {@code Runtime.Version::major} that the
* {@code JarFile} was opened with. These versioned entries are aliases
* for the real entries -- i.e. the names are base names and the content
* may come from a versioned directory entry. If the {@code jarFile} is not
* a multi-release jar, a stream of all entries is returned.
*
* @param jf the input JarFile
* @return stream of entries
* @since 9
*/
public static Stream<JarEntry> stream(JarFile jf) {
if (jf.isMultiRelease()) {
int version = jf.getVersion().major();
return jf.stream()
.map(je -> getBaseSuffix(je, version))
.filter(Objects::nonNull)
.distinct()
.map(jf::getJarEntry);
}
return jf.stream();
}