Skip to content

Commit

Permalink
feat: #81 Migrate ZipUtils to Kotlin. Close the ZipFile resource corr…
Browse files Browse the repository at this point in the history
…ectly.
  • Loading branch information
dmitry-weirdo committed Nov 22, 2024
1 parent e2e0af8 commit 2e76770
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ru.klavogonki.statistics.zip

import net.lingala.zip4j.ZipFile
import net.lingala.zip4j.exception.ZipException
import org.apache.logging.log4j.kotlin.Logging

object ZipUtils : Logging {

@JvmStatic
fun zipFile(filePath: String, zipFilePath: String) {
ZipFile(zipFilePath).use {
try {
it.addFile(filePath)

logger.debug("Successfully zipped file \"$filePath\" to zip file \"$zipFilePath\".")
} catch (e: ZipException) {
logger.error("Error on zipping file \"$filePath\" to zip file \"$zipFilePath\"", e)

throw e
}
}
}
}

0 comments on commit 2e76770

Please sign in to comment.