All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.softicar.platform.common.core.java.jar.JarFileEntryIterator Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.core.java.jar;

import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class JarFileEntryIterator implements Iterator, AutoCloseable {

	private final ZipFile zipFile;
	private Enumeration enumeration;

	public JarFileEntryIterator(File file) {

		try {
			this.zipFile = new ZipFile(file);
			this.enumeration = zipFile.entries();
		} catch (IOException exception) {
			throw new RuntimeException(exception);
		}
	}

	@Override
	public void close() {

		try {
			zipFile.close();
		} catch (IOException exception) {
			throw new RuntimeException(exception);
		}
	}

	@Override
	public boolean hasNext() {

		boolean hasMoreElements = enumeration.hasMoreElements();
		if (hasMoreElements) {
			return true;
		} else {
			close();
			return false;
		}
	}

	@Override
	public JarFileEntry next() {

		return new JarFileEntry(zipFile, enumeration.nextElement());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy