-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #81 Migrate ZipUtils to Kotlin. Close the ZipFile resource corr…
…ectly.
- Loading branch information
1 parent
e2e0af8
commit 2e76770
Showing
2 changed files
with
23 additions
and
24 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
kgstatsSrv/src/main/java/ru/klavogonki/statistics/zip/ZipUtils.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
kgstatsSrv/src/main/kotlin/ru/klavogonki/statistics/zip/ZipUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
} |