equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
59 * <p>The new output stream instance is created as if by invoking |
59 * <p>The new output stream instance is created as if by invoking |
60 * the 3-argument constructor GZIPOutputStream(out, size, false). |
60 * the 3-argument constructor GZIPOutputStream(out, size, false). |
61 * |
61 * |
62 * @param out the output stream |
62 * @param out the output stream |
63 * @param size the output buffer size |
63 * @param size the output buffer size |
64 * @exception IOException If an I/O error has occurred. |
64 * @throws IOException If an I/O error has occurred. |
65 * @exception IllegalArgumentException if {@code size <= 0} |
65 * @throws IllegalArgumentException if {@code size <= 0} |
66 */ |
66 */ |
67 public GZIPOutputStream(OutputStream out, int size) throws IOException { |
67 public GZIPOutputStream(OutputStream out, int size) throws IOException { |
68 this(out, size, false); |
68 this(out, size, false); |
69 } |
69 } |
70 |
70 |
78 * if {@code true} invocation of the inherited |
78 * if {@code true} invocation of the inherited |
79 * {@link DeflaterOutputStream#flush() flush()} method of |
79 * {@link DeflaterOutputStream#flush() flush()} method of |
80 * this instance flushes the compressor with flush mode |
80 * this instance flushes the compressor with flush mode |
81 * {@link Deflater#SYNC_FLUSH} before flushing the output |
81 * {@link Deflater#SYNC_FLUSH} before flushing the output |
82 * stream, otherwise only flushes the output stream |
82 * stream, otherwise only flushes the output stream |
83 * @exception IOException If an I/O error has occurred. |
83 * @throws IOException If an I/O error has occurred. |
84 * @exception IllegalArgumentException if {@code size <= 0} |
84 * @throws IllegalArgumentException if {@code size <= 0} |
85 * |
85 * |
86 * @since 1.7 |
86 * @since 1.7 |
87 */ |
87 */ |
88 public GZIPOutputStream(OutputStream out, int size, boolean syncFlush) |
88 public GZIPOutputStream(OutputStream out, int size, boolean syncFlush) |
89 throws IOException |
89 throws IOException |
102 * |
102 * |
103 * <p>The new output stream instance is created as if by invoking |
103 * <p>The new output stream instance is created as if by invoking |
104 * the 2-argument constructor GZIPOutputStream(out, false). |
104 * the 2-argument constructor GZIPOutputStream(out, false). |
105 * |
105 * |
106 * @param out the output stream |
106 * @param out the output stream |
107 * @exception IOException If an I/O error has occurred. |
107 * @throws IOException If an I/O error has occurred. |
108 */ |
108 */ |
109 public GZIPOutputStream(OutputStream out) throws IOException { |
109 public GZIPOutputStream(OutputStream out) throws IOException { |
110 this(out, 512, false); |
110 this(out, 512, false); |
111 } |
111 } |
112 |
112 |
120 * {@link DeflaterOutputStream#flush() flush()} method of |
120 * {@link DeflaterOutputStream#flush() flush()} method of |
121 * this instance flushes the compressor with flush mode |
121 * this instance flushes the compressor with flush mode |
122 * {@link Deflater#SYNC_FLUSH} before flushing the output |
122 * {@link Deflater#SYNC_FLUSH} before flushing the output |
123 * stream, otherwise only flushes the output stream |
123 * stream, otherwise only flushes the output stream |
124 * |
124 * |
125 * @exception IOException If an I/O error has occurred. |
125 * @throws IOException If an I/O error has occurred. |
126 * |
126 * |
127 * @since 1.7 |
127 * @since 1.7 |
128 */ |
128 */ |
129 public GZIPOutputStream(OutputStream out, boolean syncFlush) |
129 public GZIPOutputStream(OutputStream out, boolean syncFlush) |
130 throws IOException |
130 throws IOException |
136 * Writes array of bytes to the compressed output stream. This method |
136 * Writes array of bytes to the compressed output stream. This method |
137 * will block until all the bytes are written. |
137 * will block until all the bytes are written. |
138 * @param buf the data to be written |
138 * @param buf the data to be written |
139 * @param off the start offset of the data |
139 * @param off the start offset of the data |
140 * @param len the length of the data |
140 * @param len the length of the data |
141 * @exception IOException If an I/O error has occurred. |
141 * @throws IOException If an I/O error has occurred. |
142 */ |
142 */ |
143 public synchronized void write(byte[] buf, int off, int len) |
143 public synchronized void write(byte[] buf, int off, int len) |
144 throws IOException |
144 throws IOException |
145 { |
145 { |
146 super.write(buf, off, len); |
146 super.write(buf, off, len); |
149 |
149 |
150 /** |
150 /** |
151 * Finishes writing compressed data to the output stream without closing |
151 * Finishes writing compressed data to the output stream without closing |
152 * the underlying stream. Use this method when applying multiple filters |
152 * the underlying stream. Use this method when applying multiple filters |
153 * in succession to the same output stream. |
153 * in succession to the same output stream. |
154 * @exception IOException if an I/O error has occurred |
154 * @throws IOException if an I/O error has occurred |
155 */ |
155 */ |
156 public void finish() throws IOException { |
156 public void finish() throws IOException { |
157 if (!def.finished()) { |
157 if (!def.finished()) { |
158 def.finish(); |
158 def.finish(); |
159 while (!def.finished()) { |
159 while (!def.finished()) { |