Skip to content

Instantly share code, notes, and snippets.

@pfcoperez
Last active October 18, 2019 12:43
Show Gist options
  • Save pfcoperez/9f1d8f871390680b14a888f35ff057a2 to your computer and use it in GitHub Desktop.
Save pfcoperez/9f1d8f871390680b14a888f35ff057a2 to your computer and use it in GitHub Desktop.
import java.util.zip.ZipInputStream
def zipStream(zis: ZipInputStream, buffer: Array[Byte]): Stream[(String, Array[Byte])] = {
val maybeEntry = Option(zis.getNextEntry);
maybeEntry match {
case Some(entry) =>
val size = zis.read(buffer, 0, buffer.size)
(entry.getName, buffer.take(size)) #:: zipStream(zis, buffer)
case None => Stream.empty
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment