Java Utililty Methods ZipEntry Read

List of utility methods to do ZipEntry Read

Description

The list of methods to do ZipEntry Read are organized into topic(s).

Method

ZipEntrygetNextZipEntry(ZipInputStream in)
Reads the next ZIP file entry from the ZipInputStream and positions the stream at the beginning of the entry data.
try {
    return in.getNextEntry();
} catch (Exception ex) {
    throw new RuntimeException("Failed to get next entry in ZIP-file", ex);
StringgetSimpleName(ZipEntry entry)
get Simple Name
return getSimpleName(entry.getName());
FilegetZipEntry(File f, String nameToRead, String fileName)
Get an entry from the specified zip file
byte[] fileBytes = new byte[1024];
File fileOut = new File(fileName);
FileOutputStream outStream = null;
FileInputStream fileInputStream = null;
ZipInputStream zipInputStream = null;
OutputStream out = null;
ZipEntry temp;
try {
...
ZipEntrygetZipEntry(final ZipFile zipFile, final CharSequence zippedName)
A sane way of retrieving an entry from a ZipFile based on its /-delimited path name.
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
    ZipEntry entry = entries.nextElement();
    if (PATH_SEPARATORS.matcher(entry.getName()).replaceAll("/")
            .equals(PATH_SEPARATORS.matcher(zippedName).replaceAll("/")))
        return entry;
return null;
...
ZipEntrygetZipEntry(String name, ZipFile zipFile)
get Zip Entry
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
    ZipEntry entry = entries.nextElement();
    if (entry.getName().endsWith(name)) {
        return entry;
return null;
...
ZipEntrygetZipEntry(String zipEntryName)
Returns ZipEntry which is usable in both Linux and Windows.
return new ZipEntry(zipEntryName.replace(File.separator, "/"));
MapgetZipEntry(String zipFileLoc)
Get File entries and size from a zip file...
ZipInputStream zipIn = null;
Map<String, Long> entryMap = null;
try {
    zipIn = new ZipInputStream(new FileInputStream(zipFileLoc));
    ZipEntry entry = zipIn.getNextEntry();
    entryMap = new HashMap<String, Long>();
    while (entry != null) {
        if (!entry.isDirectory()) {
...
ZipEntrygetZipEntry(ZipFile jarFile, String path)
get Zip Entry
Enumeration<? extends ZipEntry> entries = jarFile.entries();
String expected = normalizePath(path);
while (entries.hasMoreElements()) {
    ZipEntry entry = entries.nextElement();
    String test = normalizePath(entry.getName());
    if (expected.equals(test)) {
        return entry;
return null;
ZipEntrygetZipEntry(ZipFile zip, final String name)
get Zip Entry
final String lcasename = name.toLowerCase();
for (Enumeration<?> itr = zip.entries(); itr.hasMoreElements();) {
    final ZipEntry zipentry = (ZipEntry) itr.nextElement();
    if (zipentry.getName().toLowerCase().equals(lcasename)) {
        return zipentry;
return null;
...
ZipEntrygetZipEntry(ZipFile zip, String name)
get Zip Entry
String lcasename = name.toLowerCase();
for (Enumeration<? extends ZipEntry> itr = zip.entries(); itr.hasMoreElements();) {
    ZipEntry zipentry = itr.nextElement();
    String entryName = zipentry.getName().toLowerCase();
    if (entryName.equals(lcasename)) {
        return zipentry;
return null;