最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论