diff --git a/kgstatsSrv/src/main/java/ru/klavogonki/statistics/zip/ZipUtils.java b/kgstatsSrv/src/main/java/ru/klavogonki/statistics/zip/ZipUtils.java deleted file mode 100644 index 4e00d10e..00000000 --- a/kgstatsSrv/src/main/java/ru/klavogonki/statistics/zip/ZipUtils.java +++ /dev/null @@ -1,24 +0,0 @@ -package ru.klavogonki.statistics.zip; - -import lombok.extern.log4j.Log4j2; -import net.lingala.zip4j.ZipFile; -import net.lingala.zip4j.exception.ZipException; - -@Log4j2 -public final class ZipUtils { - - private ZipUtils() { - } - - public static void zipFile(String filePath, String zipFilePath) { - try { - new ZipFile(zipFilePath).addFile(filePath); - logger.debug("Successfully zipped file {} to zip file {}", filePath, zipFilePath); - } - catch (ZipException e) { - logger.error(String.format("Error on zipping file %s to zip file %s", filePath, zipFilePath), e ); - - throw new RuntimeException(e); - } - } -} diff --git a/kgstatsSrv/src/main/kotlin/ru/klavogonki/statistics/zip/ZipUtils.kt b/kgstatsSrv/src/main/kotlin/ru/klavogonki/statistics/zip/ZipUtils.kt new file mode 100644 index 00000000..89e6508e --- /dev/null +++ b/kgstatsSrv/src/main/kotlin/ru/klavogonki/statistics/zip/ZipUtils.kt @@ -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 + } + } + } +} \ No newline at end of file