mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 21:30:20 +07:00
Set Gzip compression level to Deflater.BEST_COMPRESSION
(#12691)
* set gzip compression level to Deflater.BEST_COMPRESSION * Update Gzip.kt * Update Gzip.kt * Update Gzip.kt
This commit is contained in:

committed by
GitHub

parent
b0bf22e6d1
commit
997648e174
@ -5,17 +5,23 @@ import java.io.BufferedReader
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.InputStreamReader
|
||||
import java.util.zip.Deflater
|
||||
import java.util.zip.GZIPInputStream
|
||||
import java.util.zip.GZIPOutputStream
|
||||
|
||||
|
||||
object Gzip {
|
||||
|
||||
fun zip(data: String): String = encode(compress(data))
|
||||
fun unzip(data: String): String = decompress(decode(data))
|
||||
fun unzip(data: String): String = decompress(decode(data))
|
||||
|
||||
private fun compress(data: String): ByteArray {
|
||||
val bos = ByteArrayOutputStream(data.length)
|
||||
val gzip = GZIPOutputStream(bos)
|
||||
val gzip = object : GZIPOutputStream(bos) {
|
||||
init {
|
||||
def.setLevel(Deflater.BEST_COMPRESSION)
|
||||
}
|
||||
}
|
||||
gzip.write(data.toByteArray())
|
||||
gzip.close()
|
||||
val compressed = bos.toByteArray()
|
||||
|
Reference in New Issue
Block a user