java - SevenZOutputFile object instantiation takes 2 min for subsequent executions after 1st execution - Stack Overflow

Below is the code used to generate 7z file from a list of files available. where 1st time 7zipping happ

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744989549a4604817.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信