Java ZipEntry Read getSimpleName(ZipEntry entry)

Here you can find the source of getSimpleName(ZipEntry entry)

Description

get Simple Name

License

Apache License

Declaration

public static String getSimpleName(ZipEntry entry) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.zip.ZipEntry;

public class Main {
    public static String getSimpleName(ZipEntry entry) {
        return getSimpleName(entry.getName());
    }//from  w w w .  jav a  2s .co m

    public static String getSimpleName(String entryName) {
        if (entryName.endsWith("/")) {
            final int lastIndex = entryName.length() - 2;
            final int firstIndex = entryName.lastIndexOf("/", lastIndex);// -1 as last index and -1 to remove /
            return firstIndex == -1 ? entryName.substring(0, lastIndex + 1)
                    : entryName.substring(firstIndex + 1, lastIndex + 1);
        } else {
            final int firstIndex = entryName.lastIndexOf("/");
            return firstIndex == -1 ? entryName : entryName
                    .substring(firstIndex + 1);
        }
    }
}

Related

  1. getNextZipEntry(ZipInputStream in)
  2. getZipEntry(File f, String nameToRead, String fileName)
  3. getZipEntry(final ZipFile zipFile, final CharSequence zippedName)
  4. getZipEntry(String name, ZipFile zipFile)
  5. getZipEntry(String zipEntryName)