Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-193

java.io.IOException: This archives contains unclosed entries.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • None
    • Windows Server 2008 R2

    Description

      I am getting java.io.IOException: This archives contains unclosed entries.
      Below is the code. Any help is much appreciated

      final File output = new File("c:\\testdata", "shishir.zip"); 
      final File file1 = new File ("C:\\testdata\test1.xml"); 
      final File file2 = new File ("C:\\testdata\test2.xml"); 
      
      final OutputStream out = new FileOutputStream(output); 
      ArchiveOutputStream os = null; 
      FileInputStream input1=null;
      FileInputStream input2=null;
      try { 
          os = new ArchiveStreamFactory() 
              .createArchiveOutputStream("zip", out); 
          os.putArchiveEntry(new ZipArchiveEntry("testdata\test1.xml")); 
          input1 = new FileInputStream(file1);
          IOUtils.copy(input1, os); 
          input1.close();
          os.closeArchiveEntry(); 
          input2 = new FileInputStream(file2);
          input2.close();
          os.putArchiveEntry(new ZipArchiveEntry("testdata\test2.xml")); 
          IOUtils.copy(input2, os); 
          os.closeArchiveEntry(); 
          os.finish();
      } finally { 
          if (os != null) {
              os.close(); 
          }else if (out != null) {
              out.close();
          } 
      } 
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            shishir06 Shishir goswami
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: