TP-62631 | Null pointer exception handling

This commit is contained in:
yashmantri
2024-07-01 15:59:45 +05:30
parent 7a816cdadc
commit ef95080cf4

View File

@@ -50,18 +50,27 @@ public class FileZipper {
ZipOutputStream zos = new ZipOutputStream(fos);
zos.setLevel(Deflater.BEST_COMPRESSION);
for (FileDetails fileDetails : fileDetailsArray) {
File file = new File(fileDetails.getPath());
FileInputStream fis = new FileInputStream(file);
zos.putNextEntry(new ZipEntry(fileDetails.getName()));
if(fileDetailsArray != null) {
for (FileDetails fileDetails : fileDetailsArray) {
if(fileDetails != null) {
String filePath = fileDetails.getPath();
String fileName = fileDetails.getName();
int length;
while ((length = fis.read(buffer)) > 0) {
zos.write(buffer, 0, length);
if(filePath != null && fileName != null) {
File file = new File(filePath);
FileInputStream fis = new FileInputStream(file);
zos.putNextEntry(new ZipEntry(fileName));
int length;
while ((length = fis.read(buffer)) > 0) {
zos.write(buffer, 0, length);
}
zos.closeEntry();
fis.close();
}
}
}
zos.closeEntry();
fis.close();
}
zos.close();