Below is the code used to generate 7z file from a list of files available. where 1st time 7zipping happens in few milli seconds for the same files from 2nd time onwards taking 2 min to 7zip.
try (.apachemonspress.archivers.sevenz.SevenZOutputFile sevenZOutputFile = new .apachemonspress.archivers.sevenz.SevenZOutputFile(opFile, password.toCharArray())) {
while (itResults.hasNext()) {
ClipboardProperty objOneResult = (ClipboardProperty)itResults.next();
ClipboardPage objResultPage = objOneResult.getPageValue();
String fileName = objResultPage.getStringIfPresent(fileNameProperty);
String fileBase64 = objResultPage.getStringIfPresent(fileBase64Property);
if (!EmptyUtils.isNullOrEmpty(fileName) && !EmptyUtils.isNullOrEmpty(fileBase64)) {
byte[]fileContent = Base64Util.decodeToByteArray(fileBase64);
.apachemonspress.archivers.sevenz.SevenZArchiveEntry entry = new .apachemonspress.archivers.sevenz.SevenZArchiveEntry();
entry.setName(fileName);
sevenZOutputFile.putArchiveEntry(entry);
sevenZOutputFile.write(fileContent, 0, fileContent.length);
sevenZOutputFile.closeArchiveEntry();
}
}
}
anything we are missing like closing streams or files? so that its taking more time subsequently. Because when we take fresh thread to execute and it works fine again by completing in few millis. Note is everytime a new 7z file name, the same files are 7zipped but still the variation between 1st and subsequent executions.
I'm expecting subsequent execution also similar to 1st execution