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

Create a finish() method similar to the java.util.zip.GZIPOutputStream#finish()

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None

      Description

      In order to write mixed (compressed/not comressed) data into an output stream it would be helpful if the CBZip2OutputStream would implement a finish() method, which is almost the same as the close() method but does not close the underlying output stream, so that writing to this stream can be continued.

        Activity

        Hide
        tcurdt Torsten Curdt added a comment -

        got a seperate finish() method now. In order to not close the stream you should wrap the stream in a delegating NonClosingOutputStream and you are good to go.

        Show
        tcurdt Torsten Curdt added a comment - got a seperate finish() method now. In order to not close the stream you should wrap the stream in a delegating NonClosingOutputStream and you are good to go.
        Hide
        ebourg Emmanuel Bourg added a comment -
        Show
        ebourg Emmanuel Bourg added a comment - Related to this Ant issue : https://issues.apache.org/bugzilla/show_bug.cgi?id=42713
        Hide
        stefan liebig Stefan Liebig added a comment -

        Patch:

        boolean closed = false;
        boolean finished = false;

        protected void finalize() throws Throwable

        { close(); super.finalize(); }

        /**

        • Finishes writing compressed data to the output stream without closing the underlying stream.
        • Use this method when applying multiple filters in succession to the same output stream.
        • @throws IOException
          */
          public void finish() throws IOException {
          if ( finished ) { return; }

          if ( runLength > 0 ) { writeRun(); }
          currentChar = -1;
          endBlock();
          endCompression();
          flush();
          finished = true;
          }

          public void close() throws IOException {
          if ( closed ) { return; }

        finish();
        closed = true;
        super.close();
        bsStream.close();
        }

        Show
        stefan liebig Stefan Liebig added a comment - Patch: boolean closed = false; boolean finished = false; protected void finalize() throws Throwable { close(); super.finalize(); } /** Finishes writing compressed data to the output stream without closing the underlying stream. Use this method when applying multiple filters in succession to the same output stream. @throws IOException */ public void finish() throws IOException { if ( finished ) { return; } if ( runLength > 0 ) { writeRun(); } currentChar = -1; endBlock(); endCompression(); flush(); finished = true; } public void close() throws IOException { if ( closed ) { return; } finish(); closed = true; super.close(); bsStream.close(); }

          People

          • Assignee:
            tcurdt Torsten Curdt
            Reporter:
            stefan liebig Stefan Liebig
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development