equal
deleted
inserted
replaced
534 * the central directory of the jar file. |
534 * the central directory of the jar file. |
535 * |
535 * |
536 * @return an ordered {@code Stream} of entries in this jar file |
536 * @return an ordered {@code Stream} of entries in this jar file |
537 * @throws IllegalStateException if the jar file has been closed |
537 * @throws IllegalStateException if the jar file has been closed |
538 * @since 1.8 |
538 * @since 1.8 |
539 * |
|
540 * @apiNote A versioned view of the stream obtained from a {@code JarFile} |
|
541 * configured to process a multi-release jar file can be created with code |
|
542 * similar to the following: |
|
543 * <pre> |
|
544 * {@code |
|
545 * Stream<JarEntry> versionedStream(JarFile jf) { |
|
546 * return jf.stream().map(JarEntry::getName) |
|
547 * .filter(name -> !name.startsWith("META-INF/versions/")) |
|
548 * .map(jf::getJarEntry); |
|
549 * } |
|
550 * } |
|
551 * </pre> |
|
552 */ |
539 */ |
553 public Stream<JarEntry> stream() { |
540 public Stream<JarEntry> stream() { |
554 return StreamSupport.stream(Spliterators.spliterator( |
541 return StreamSupport.stream(Spliterators.spliterator( |
555 new JarEntryIterator(), size(), |
542 new JarEntryIterator(), size(), |
556 Spliterator.ORDERED | Spliterator.DISTINCT | |
543 Spliterator.ORDERED | Spliterator.DISTINCT | |
569 return vze; |
556 return vze; |
570 } |
557 } |
571 |
558 |
572 private ZipEntry getVersionedEntry(ZipEntry ze) { |
559 private ZipEntry getVersionedEntry(ZipEntry ze) { |
573 ZipEntry vze = null; |
560 ZipEntry vze = null; |
574 if (BASE_VERSION_MAJOR < versionMajor && !ze.isDirectory()) { |
561 if (BASE_VERSION_MAJOR < versionMajor) { |
575 String name = ze.getName(); |
562 String name = ze.getName(); |
576 if (!name.startsWith(META_INF)) { |
563 if (!name.startsWith(META_INF)) { |
577 vze = searchForVersionedEntry(versionMajor, name); |
564 vze = searchForVersionedEntry(versionMajor, name); |
578 } |
565 } |
579 } |
566 } |