mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -4,6 +4,7 @@ import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
import java.io.*
|
||||
import java.util.zip.GZIPOutputStream
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
import java.util.zip.ZipOutputStream
|
||||
@@ -11,6 +12,17 @@ import java.util.zip.ZipOutputStream
|
||||
@Suppress("unused", "BlockingMethodInNonBlockingContext", "MemberVisibilityCanBePrivate")
|
||||
object ZipUtils {
|
||||
|
||||
fun zipString(text: String): ByteArray {
|
||||
val byteOut = ByteArrayOutputStream()
|
||||
val zip = GZIPOutputStream(byteOut)
|
||||
zip.use {
|
||||
it.write(text.toByteArray())
|
||||
}
|
||||
return byteOut.use {
|
||||
it.toByteArray()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zip the files.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user