diff --git a/src/main/java/sh/rhiobet/lalafin/path/ZipEntryPath.java b/src/main/java/sh/rhiobet/lalafin/path/ZipEntryPath.java index 521421c..5f1ca29 100644 --- a/src/main/java/sh/rhiobet/lalafin/path/ZipEntryPath.java +++ b/src/main/java/sh/rhiobet/lalafin/path/ZipEntryPath.java @@ -72,12 +72,24 @@ public final class ZipEntryPath implements Path { @Override public InputStream getInputStream() throws IOException { - ZipFile zipFile = new ZipFile(this.zipFilePath.absolutePath.toFile()); - return new ZipEntryInputStream(zipFile, - zipFile.getInputStream(zipFile.getEntry(this.entryName))); + if (this.zipFilePath.exists()) { + ZipFile zipFile = new ZipFile(this.zipFilePath.absolutePath.toFile()); + ZipEntry zipEntry = zipFile.getEntry(this.entryName); + if (zipEntry != null) { + return new ZipEntryInputStream(zipFile, zipFile.getInputStream(zipEntry)); + } else { + throw new IOException("Zip entry does not exist."); + } + } else { + throw new IOException("Zip file does not exist."); + } } private void fetchEntryData() { + if (!this.zipFilePath.exists()) { + return; + } + try (ZipFile zipFile = new ZipFile(this.zipFilePath.absolutePath.toFile())) { ZipEntry zipEntry = zipFile.getEntry(this.entryName); this.exists = zipEntry != null;