public static String getFileName(String compressedName) {
    compressedName = compressedName.toLowerCase();
    boolean hasFileName = compressedName.contains(".");
    if (hasFileName
        && (isZip(compressedName)
            || isTar(compressedName)
            || isRar(compressedName)
            || is7zip(compressedName)
            || isXz(compressedName)
            || isLzma(compressedName)
            || isGzip(compressedName)
            || compressedName.endsWith(fileExtensionGzipTarShort)
            || compressedName.endsWith(fileExtensionBzip2TarShort)
            || isGzip(compressedName)
            || isBzip2(compressedName)
            || isLzma(compressedName)
            || isXz(compressedName))) {
      return compressedName.substring(0, compressedName.lastIndexOf("."));
    } else if (hasFileName && isGzippedTar(compressedName)
        || isXzippedTar(compressedName)
        || isLzippedTar(compressedName)
        || isBzippedTar(compressedName)) {
      return compressedName.substring(0, Utils.nthToLastCharIndex(2, compressedName, '.'));
    } else {
      return compressedName;
    }
  }
@Test
  public void getFileNameTest() throws Exception {
    assertEquals("test", CompressedHelper.getFileName("test.zip"));
    assertEquals("test", CompressedHelper.getFileName("test.rar"));
    assertEquals("test", CompressedHelper.getFileName("test.tar"));
    assertEquals("test", CompressedHelper.getFileName("test.tar.gz"));
    assertEquals("test", CompressedHelper.getFileName("test.tgz"));
    assertEquals("test", CompressedHelper.getFileName("test.tar.bz2"));
    assertEquals("test", CompressedHelper.getFileName("test.tbz"));
    assertEquals("test", CompressedHelper.getFileName("test.tar.lzma"));
    assertEquals("test", CompressedHelper.getFileName("test.jar"));
    assertEquals("test", CompressedHelper.getFileName("test.apk"));
    assertEquals("test", CompressedHelper.getFileName("test.7z"));

    assertEquals("test.txt", CompressedHelper.getFileName("test.txt.gz"));
    assertEquals("test.txt", CompressedHelper.getFileName("test.txt.bz2"));
    assertEquals("test.txt", CompressedHelper.getFileName("test.txt.lzma"));
    assertEquals("test.txt", CompressedHelper.getFileName("test.txt.xz"));

    // no extension(directory)
    assertEquals("test", CompressedHelper.getFileName("test"));

    // invalid extension
    assertEquals("test.z", CompressedHelper.getFileName("test.z"));

    // no path
    assertEquals("", CompressedHelper.getFileName(""));
  }