TP-62631 | Null pointer exception handling

This commit is contained in:
yashmantri
2024-07-01 16:17:22 +05:30
parent ef95080cf4
commit de0f3141c9

View File

@@ -58,16 +58,18 @@ public class FileZipper {
if(filePath != null && fileName != null) {
File file = new File(filePath);
FileInputStream fis = new FileInputStream(file);
zos.putNextEntry(new ZipEntry(fileName));
if(file != null) {
FileInputStream fis = new FileInputStream(file);
zos.putNextEntry(new ZipEntry(fileName));
int length;
while ((length = fis.read(buffer)) > 0) {
zos.write(buffer, 0, length);
int length;
while ((length = fis.read(buffer)) > 0) {
zos.write(buffer, 0, length);
}
zos.closeEntry();
fis.close();
}
zos.closeEntry();
fis.close();
}
}
}