io.appmetrica.gradle.aarcheck.utils.ZipUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aar-check Show documentation
Show all versions of aar-check Show documentation
Provides plugin for check aar
The newest version!
package io.appmetrica.gradle.aarcheck.utils
import java.io.File
import java.util.jar.JarEntry
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
fun ZipFile.extractEntry(entryName: String): File {
return extractEntry(getEntry(entryName))
}
fun ZipFile.extractEntry(entry: ZipEntry): File {
val entryFile = File.createTempFile(name, entry.name.replace('/', '_'))
entryFile.deleteOnExit()
getInputStream(entry).use { entryInput ->
entryFile.outputStream().use { entryFileOutput ->
entryInput.copyTo(entryFileOutput)
}
}
return entryFile
}
fun ZipFile.readFile(name: String): String {
return getInputStream(getEntry(name)).use {
it.bufferedReader().readText()
}
}
fun JarEntry.isClass() = name.endsWith(".class")
© 2015 - 2025 Weber Informatics LLC | Privacy Policy