37 *
38 * @see Deflater
39 * @author David Connelly
40 * @since 1.1
41 */
42 public
43 class DeflaterOutputStream extends FilterOutputStream {
44 /**
45 * Compressor for this stream.
46 */
47 protected Deflater def;
48
49 /**
50 * Output buffer for writing compressed data.
51 */
52 protected byte[] buf;
53
54 /**
55 * Indicates that the stream has been closed.
56 */
57
58 private boolean closed = false;
59
60 private final boolean syncFlush;
61
62 /**
63 * Creates a new output stream with the specified compressor,
64 * buffer size and flush mode.
65
66 * @param out the output stream
67 * @param def the compressor ("deflater")
68 * @param size the output buffer size
69 * @param syncFlush
70 * if {@code true} the {@link #flush()} method of this
71 * instance flushes the compressor with flush mode
72 * {@link Deflater#SYNC_FLUSH} before flushing the output
73 * stream, otherwise only flushes the output stream
74 *
75 * @throws IllegalArgumentException if {@code size <= 0}
76 *
77 * @since 1.7
78 */
79 public DeflaterOutputStream(OutputStream out,
80 Deflater def,
81 int size,
82 boolean syncFlush) {
83 super(out);
84 if (out == null || def == null) {
85 throw new NullPointerException();
|
37 *
38 * @see Deflater
39 * @author David Connelly
40 * @since 1.1
41 */
42 public
43 class DeflaterOutputStream extends FilterOutputStream {
44 /**
45 * Compressor for this stream.
46 */
47 protected Deflater def;
48
49 /**
50 * Output buffer for writing compressed data.
51 */
52 protected byte[] buf;
53
54 /**
55 * Indicates that the stream has been closed.
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();
|