com.deviniti.testflo.testsender.ZipFileCreator.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of test-results-sender Show documentation
Show all versions of test-results-sender Show documentation
TestFLO - Test result sender
package com.deviniti.testflo.testsender
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
fun createZipFile(inputFiles: List): File {
val resultZipFile = File.createTempFile("test-results", ".zip")
ZipOutputStream(FileOutputStream(resultZipFile)).use { resultZipFileOutputStream ->
inputFiles.forEachIndexed { index, resultFile ->
val zipEntry = ZipEntry("$index-${resultFile.name}")
resultZipFileOutputStream.putNextEntry(zipEntry)
FileInputStream(resultFile).use { resultFileInputStream ->
resultFileInputStream.copyTo(resultZipFileOutputStream)
}
}
}
return resultZipFile
}