src/share/classes/java/util/zip/DeflaterOutputStream.java

Print this page




  54      * Indicates that the stream has been closed.
  55      */
  56 
  57     private boolean closed = false;
  58 
  59     private final boolean syncFlush;
  60 
  61     /**
  62      * Creates a new output stream with the specified compressor,
  63      * buffer size and flush mode.
  64 
  65      * @param out the output stream
  66      * @param def the compressor ("deflater")
  67      * @param size the output buffer size
  68      * @param syncFlush
  69      *        if {@code true} the {@link #flush()} method of this
  70      *        instance flushes the compressor with flush mode
  71      *        {@link Deflater#SYNC_FLUSH} before flushing the output
  72      *        stream, otherwise only flushes the output stream
  73      *
  74      * @throws IllegalArgumentException if size is <= 0
  75      *
  76      * @since 1.7
  77      */
  78     public DeflaterOutputStream(OutputStream out,
  79                                 Deflater def,
  80                                 int size,
  81                                 boolean syncFlush) {
  82         super(out);
  83         if (out == null || def == null) {
  84             throw new NullPointerException();
  85         } else if (size <= 0) {
  86             throw new IllegalArgumentException("buffer size <= 0");
  87         }
  88         this.def = def;
  89         this.buf = new byte[size];
  90         this.syncFlush = syncFlush;
  91     }
  92 
  93 
  94     /**
  95      * Creates a new output stream with the specified compressor and
  96      * buffer size.
  97      *
  98      * <p>The new output stream instance is created as if by invoking
  99      * the 4-argument constructor DeflaterOutputStream(out, def, size, false).
 100      *
 101      * @param out the output stream
 102      * @param def the compressor ("deflater")
 103      * @param size the output buffer size
 104      * @exception IllegalArgumentException if size is <= 0
 105      */
 106     public DeflaterOutputStream(OutputStream out, Deflater def, int size) {
 107         this(out, def, size, false);
 108     }
 109 
 110     /**
 111      * Creates a new output stream with the specified compressor, flush
 112      * mode and a default buffer size.
 113      *
 114      * @param out the output stream
 115      * @param def the compressor ("deflater")
 116      * @param syncFlush
 117      *        if {@code true} the {@link #flush()} method of this
 118      *        instance flushes the compressor with flush mode
 119      *        {@link Deflater#SYNC_FLUSH} before flushing the output
 120      *        stream, otherwise only flushes the output stream
 121      *
 122      * @since 1.7
 123      */
 124     public DeflaterOutputStream(OutputStream out,




  54      * Indicates that the stream has been closed.
  55      */
  56 
  57     private boolean closed = false;
  58 
  59     private final boolean syncFlush;
  60 
  61     /**
  62      * Creates a new output stream with the specified compressor,
  63      * buffer size and flush mode.
  64 
  65      * @param out the output stream
  66      * @param def the compressor ("deflater")
  67      * @param size the output buffer size
  68      * @param syncFlush
  69      *        if {@code true} the {@link #flush()} method of this
  70      *        instance flushes the compressor with flush mode
  71      *        {@link Deflater#SYNC_FLUSH} before flushing the output
  72      *        stream, otherwise only flushes the output stream
  73      *
  74      * @throws IllegalArgumentException if {@code size <= 0}
  75      *
  76      * @since 1.7
  77      */
  78     public DeflaterOutputStream(OutputStream out,
  79                                 Deflater def,
  80                                 int size,
  81                                 boolean syncFlush) {
  82         super(out);
  83         if (out == null || def == null) {
  84             throw new NullPointerException();
  85         } else if (size <= 0) {
  86             throw new IllegalArgumentException("buffer size <= 0");
  87         }
  88         this.def = def;
  89         this.buf = new byte[size];
  90         this.syncFlush = syncFlush;
  91     }
  92 
  93 
  94     /**
  95      * Creates a new output stream with the specified compressor and
  96      * buffer size.
  97      *
  98      * <p>The new output stream instance is created as if by invoking
  99      * the 4-argument constructor DeflaterOutputStream(out, def, size, false).
 100      *
 101      * @param out the output stream
 102      * @param def the compressor ("deflater")
 103      * @param size the output buffer size
 104      * @exception IllegalArgumentException if {@code size <= 0}
 105      */
 106     public DeflaterOutputStream(OutputStream out, Deflater def, int size) {
 107         this(out, def, size, false);
 108     }
 109 
 110     /**
 111      * Creates a new output stream with the specified compressor, flush
 112      * mode and a default buffer size.
 113      *
 114      * @param out the output stream
 115      * @param def the compressor ("deflater")
 116      * @param syncFlush
 117      *        if {@code true} the {@link #flush()} method of this
 118      *        instance flushes the compressor with flush mode
 119      *        {@link Deflater#SYNC_FLUSH} before flushing the output
 120      *        stream, otherwise only flushes the output stream
 121      *
 122      * @since 1.7
 123      */
 124     public DeflaterOutputStream(OutputStream out,