【Android】ZipInputStream获取压缩包根目录文件夹名称

avatar

azurekiln

fun getZipRootDirName(zipFile: File): String? {
    ZipInputStream(FileInputStream(zipFile)).use { zis ->
        val firstEntry = zis.nextEntry
        if (firstEntry != null) {
            val name = firstEntry.name
            val index = name.indexOf('/')
            if (index != -1) {
                return name.substring(0, index)
            }
        }
    }
    return null
}

扫描二维码,在手机上阅读
收藏
请先 登录 再评论
powered by emlog pro
服务器供应商 景云数据

友情链接
白衣Ink


sitemap