good day!
Let’s say that I have a folder named “Data” which contains multiple folders:
- Data1_Folder.
- Data2_Folder.
- Data3_Folder.
- Data4_Folder.
and I need to compress only Data2_Folder and Data3_Folder, In another words, the user will decide which folders he wants to compress.
I’m using a for loop to read data from DB for chosen IDs and write these data in separate excel sheets. all of the files will be stored under their ID name folder (Data#_Folder) under the main Data folder.
at the end of the loop these are the statements to create the file and compress them.
Excel.writeFile((String)DataID.get(i),TempArray);
Folder2Compress = new String[]{CompressingFolders.CompressFiles("D:\\Data/"+DataID.get(i).toString())};
unfortunately, only the last created folder will be compressed. How can I make it to compress all chosen folders?
Thanks in advance.
You add only a single folder to the array
Folder2Compress. Use aList<String>instead and add all folders to the list:Now you can change
CompressingFolders.CompressFiles()to take this list as input and add all folders to the result.Note: You may want to look at the Java naming convention.