X-Git-Url: https://juplo.de/gitweb/?p=scannotation;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fscannotation%2Fclasspath%2FJarIterator.java;fp=src%2Fmain%2Fjava%2Forg%2Fscannotation%2Fclasspath%2FJarIterator.java;h=0000000000000000000000000000000000000000;hp=dd4cf3579f700de5884ff2df6e0068a1eab20595;hb=36e6637926203201648e7892ec6ee1240807218e;hpb=58b6663aae5313b41167d92851981ca549cbb461 diff --git a/src/main/java/org/scannotation/classpath/JarIterator.java b/src/main/java/org/scannotation/classpath/JarIterator.java deleted file mode 100644 index dd4cf35..0000000 --- a/src/main/java/org/scannotation/classpath/JarIterator.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.scannotation.classpath; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class JarIterator implements StreamIterator -{ - JarInputStream jar; - JarEntry next; - Filter filter; - boolean initial = true; - boolean closed = false; - - public JarIterator(File file, Filter filter) throws IOException - { - this(new FileInputStream(file), filter); - } - - - public JarIterator(InputStream is, Filter filter) throws IOException - { - this.filter = filter; - jar = new JarInputStream(is); - } - - private void setNext() - { - initial = true; - try - { - if (next != null) jar.closeEntry(); - next = null; - do - { - next = jar.getNextJarEntry(); - } while (next != null && (next.isDirectory() || (filter == null || !filter.accepts(next.getName())))); - if (next == null) - { - close(); - } - } - catch (IOException e) - { - throw new RuntimeException("failed to browse jar", e); - } - } - - public InputStream next() - { - if (closed || (next == null && !initial)) return null; - setNext(); - if (next == null) return null; - return new InputStreamWrapper(jar); - } - - public void close() - { - try - { - closed = true; - jar.close(); - } - catch (IOException ignored) - { - - } - - } -}