Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def compress(input: Array[Byte]): Array[Byte] = {
- val bos = new ByteArrayOutputStream(input.length)
- val gzip = new GZIPOutputStream(bos)
- gzip.write(input)
- gzip.close()
- val compressed = bos.toByteArray
- bos.close()
- compressed
- }
- def decompress(compressed: Array[Byte]): Option[String] =
- Try {
- val inputStream = new GZIPInputStream(new ByteArrayInputStream(compressed))
- scala.io.Source.fromInputStream(inputStream).mkString
- }.toOption
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement