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

Print this page

        

*** 1,7 **** /* ! * Copyright 1996-2002 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this --- 1,7 ---- /* ! * Copyright 1996-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this
*** 52,82 **** */ private final static int TRAILER_SIZE = 8; /** * Creates a new output stream with the specified buffer size. * @param out the output stream * @param size the output buffer size * @exception IOException If an I/O error has occurred. * @exception IllegalArgumentException if size is <= 0 */ public GZIPOutputStream(OutputStream out, int size) throws IOException { ! super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size); usesDefaultDeflater = true; writeHeader(); crc.reset(); } /** * Creates a new output stream with a default buffer size. * @param out the output stream * @exception IOException If an I/O error has occurred. */ public GZIPOutputStream(OutputStream out) throws IOException { ! this(out, 512); } /** * Writes array of bytes to the compressed output stream. This method * will block until all the bytes are written. * @param buf the data to be written * @param off the start offset of the data --- 52,139 ---- */ private final static int TRAILER_SIZE = 8; /** * Creates a new output stream with the specified buffer size. + * + * <p>The new output stream instance is created as if by invoking + * the 3-argument constructor GZIPOutputStream(out, size, false). + * * @param out the output stream * @param size the output buffer size * @exception IOException If an I/O error has occurred. * @exception IllegalArgumentException if size is <= 0 + */ public GZIPOutputStream(OutputStream out, int size) throws IOException { ! this(out, size, false); ! } ! ! /** ! * Creates a new output stream with the specified buffer size and ! * flush mode. ! * ! * @param out the output stream ! * @param size the output buffer size ! * @param syncFlush ! * if {@code true} invocation of the inherited ! * {@link DeflaterOutputStream#flush() flush()} method of ! * this instance flushes the compressor with flush mode ! * {@link Deflater#SYNC_FLUSH} before flushing the output ! * stream, otherwise only flushes the output stream ! * @exception IOException If an I/O error has occurred. ! * @exception IllegalArgumentException if size is <= 0 ! * ! * @since 1.7 ! */ ! public GZIPOutputStream(OutputStream out, int size, boolean syncFlush) ! throws IOException ! { ! super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true), ! size, ! syncFlush); usesDefaultDeflater = true; writeHeader(); crc.reset(); } + /** * Creates a new output stream with a default buffer size. + * + * <p>The new output stream instance is created as if by invoking + * the 2-argument constructor GZIPOutputStream(out, false). + * * @param out the output stream * @exception IOException If an I/O error has occurred. */ public GZIPOutputStream(OutputStream out) throws IOException { ! this(out, 512, false); } + /** + * Creates a new output stream with a default buffer size and + * the specified flush mode. + * + * @param out the output stream + * @param syncFlush + * if {@code true} invocation of the inherited + * {@link DeflaterOutputStream#flush() flush()} method of + * this instance flushes the compressor with flush mode + * {@link Deflater#SYNC_FLUSH} before flushing the output + * stream, otherwise only flushes the output stream + * + * @exception IOException If an I/O error has occurred. + * + * @since 1.7 + */ + public GZIPOutputStream(OutputStream out, boolean syncFlush) + throws IOException + { + this(out, 512, syncFlush); + } + /** * Writes array of bytes to the compressed output stream. This method * will block until all the bytes are written. * @param buf the data to be written * @param off the start offset of the data