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

Print this page




  44     /*
  45      * GZIP header magic number.
  46      */
  47     private final static int GZIP_MAGIC = 0x8b1f;
  48 
  49     /*
  50      * Trailer size in bytes.
  51      *
  52      */
  53     private final static int TRAILER_SIZE = 8;
  54 
  55     /**
  56      * Creates a new output stream with the specified buffer size.
  57      *
  58      * <p>The new output stream instance is created as if by invoking
  59      * the 3-argument constructor GZIPOutputStream(out, size, false).
  60      *
  61      * @param out the output stream
  62      * @param size the output buffer size
  63      * @exception IOException If an I/O error has occurred.
  64      * @exception IllegalArgumentException if size is <= 0
  65 
  66      */
  67     public GZIPOutputStream(OutputStream out, int size) throws IOException {
  68         this(out, size, false);
  69     }
  70 
  71     /**
  72      * Creates a new output stream with the specified buffer size and
  73      * flush mode.
  74      *
  75      * @param out the output stream
  76      * @param size the output buffer size
  77      * @param syncFlush
  78      *        if {@code true} invocation of the inherited
  79      *        {@link DeflaterOutputStream#flush() flush()} method of
  80      *        this instance flushes the compressor with flush mode
  81      *        {@link Deflater#SYNC_FLUSH} before flushing the output
  82      *        stream, otherwise only flushes the output stream
  83      * @exception IOException If an I/O error has occurred.
  84      * @exception IllegalArgumentException if size is <= 0
  85      *
  86      * @since 1.7
  87      */
  88     public GZIPOutputStream(OutputStream out, int size, boolean syncFlush)
  89         throws IOException
  90     {
  91         super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true),
  92               size,
  93               syncFlush);
  94         usesDefaultDeflater = true;
  95         writeHeader();
  96         crc.reset();
  97     }
  98 
  99 
 100     /**
 101      * Creates a new output stream with a default buffer size.
 102      *
 103      * <p>The new output stream instance is created as if by invoking
 104      * the 2-argument constructor GZIPOutputStream(out, false).




  44     /*
  45      * GZIP header magic number.
  46      */
  47     private final static int GZIP_MAGIC = 0x8b1f;
  48 
  49     /*
  50      * Trailer size in bytes.
  51      *
  52      */
  53     private final static int TRAILER_SIZE = 8;
  54 
  55     /**
  56      * Creates a new output stream with the specified buffer size.
  57      *
  58      * <p>The new output stream instance is created as if by invoking
  59      * the 3-argument constructor GZIPOutputStream(out, size, false).
  60      *
  61      * @param out the output stream
  62      * @param size the output buffer size
  63      * @exception IOException If an I/O error has occurred.
  64      * @exception IllegalArgumentException if {@code size <= 0}

  65      */
  66     public GZIPOutputStream(OutputStream out, int size) throws IOException {
  67         this(out, size, false);
  68     }
  69 
  70     /**
  71      * Creates a new output stream with the specified buffer size and
  72      * flush mode.
  73      *
  74      * @param out the output stream
  75      * @param size the output buffer size
  76      * @param syncFlush
  77      *        if {@code true} invocation of the inherited
  78      *        {@link DeflaterOutputStream#flush() flush()} method of
  79      *        this instance flushes the compressor with flush mode
  80      *        {@link Deflater#SYNC_FLUSH} before flushing the output
  81      *        stream, otherwise only flushes the output stream
  82      * @exception IOException If an I/O error has occurred.
  83      * @exception IllegalArgumentException if {@code size <= 0}
  84      *
  85      * @since 1.7
  86      */
  87     public GZIPOutputStream(OutputStream out, int size, boolean syncFlush)
  88         throws IOException
  89     {
  90         super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true),
  91               size,
  92               syncFlush);
  93         usesDefaultDeflater = true;
  94         writeHeader();
  95         crc.reset();
  96     }
  97 
  98 
  99     /**
 100      * Creates a new output stream with a default buffer size.
 101      *
 102      * <p>The new output stream instance is created as if by invoking
 103      * the 2-argument constructor GZIPOutputStream(out, false).