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


Java JarFile.stream方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:StreamZipEntriesTest.java

示例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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:VersionedStream.java


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