mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
57fca59249
commit
24943b1d6b
@ -4,6 +4,7 @@ import kotlinx.coroutines.Dispatchers.IO
|
|||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
|
import java.util.zip.GZIPOutputStream
|
||||||
import java.util.zip.ZipEntry
|
import java.util.zip.ZipEntry
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
import java.util.zip.ZipOutputStream
|
import java.util.zip.ZipOutputStream
|
||||||
@ -11,6 +12,17 @@ import java.util.zip.ZipOutputStream
|
|||||||
@Suppress("unused", "BlockingMethodInNonBlockingContext", "MemberVisibilityCanBePrivate")
|
@Suppress("unused", "BlockingMethodInNonBlockingContext", "MemberVisibilityCanBePrivate")
|
||||||
object ZipUtils {
|
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.
|
* Zip the files.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user