Skip to content

Commit

Permalink
Improve ZipUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
IndianBartonka committed Sep 5, 2024
1 parent 8256930 commit 0e0ef51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.indian.util</groupId>
<artifactId>utils</artifactId>
<version>0.0.3-Beta</version>
<version>0.0.3</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/me/indian/util/ZipUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ public static void zipFolder(final String sourceFolderPath, final String zipFile
* @param zipFilePath The path where the ZIP file will be created.
* @throws Exception If an error occurs during the zipping process.
*/
public static void zipFiles(final List<String> srcFiles, final String zipFilePath) throws Exception {
public static void zipFiles(final File[] srcFiles, final String zipFilePath) throws Exception {
try (final FileOutputStream fos = new FileOutputStream(zipFilePath);
final ZipOutputStream zipOut = new ZipOutputStream(fos)) {
for (final String srcFile : srcFiles) {
final File fileToZip = new File(srcFile);
if (!fileToZip.exists()) continue;
try (final FileInputStream fis = new FileInputStream(fileToZip)) {
final ZipEntry zipEntry = new ZipEntry(fileToZip.getName());
for (final File srcFile : srcFiles) {
if (!srcFile.exists()) continue;
try (final FileInputStream fis = new FileInputStream(srcFile)) {
final ZipEntry zipEntry = new ZipEntry(srcFile.getName());
zipOut.putNextEntry(zipEntry);
final byte[] bytes = new byte[1024];
int length;
Expand Down

0 comments on commit 0e0ef51

Please sign in to comment.