From de0f3141c9f502459b8833fd4e0be696ebbe5a29 Mon Sep 17 00:00:00 2001 From: yashmantri Date: Mon, 1 Jul 2024 16:17:22 +0530 Subject: [PATCH] TP-62631 | Null pointer exception handling --- .../com/avapp/deviceDataSync/FileZipper.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/android/app/src/main/java/com/avapp/deviceDataSync/FileZipper.java b/android/app/src/main/java/com/avapp/deviceDataSync/FileZipper.java index 353bf7f2..e4c59373 100644 --- a/android/app/src/main/java/com/avapp/deviceDataSync/FileZipper.java +++ b/android/app/src/main/java/com/avapp/deviceDataSync/FileZipper.java @@ -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(); } } }