Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 886
نمايش فراداده

DeflaterOutputStreamjava.util.zip

Java 1.1closeable flushable

This class is a subclass of java.io.FilterOutputStream; it filters a stream of data by compressing (deflating) it and then writing the compressed data to another output stream. To create a DeflaterOutputStream, you must specify both the stream it is to write to and a Deflater object to perform the compression. You can set various options on the Deflater object to specify just what type of compression is to be performed. Once a DeflaterOutputStream is created, its write( ) and close( ) methods are the same as those of other output streams. The InflaterInputStream class can read data written with a DeflaterOutputStream. A DeflaterOutputStream writes raw compressed data; applications often prefer one of its subclasses, GZIPOutputStream or ZipOutputStream, that wraps the raw compressed data within a standard file format.

Figure 16-139. java.util.zip.DeflaterOutputStream

public class

DeflaterOutputStream extends java.io.FilterOutputStream { // Public Constructors public

DeflaterOutputStream (java.io.OutputStream

out ); public

DeflaterOutputStream (java.io.OutputStream

out , Deflater

def ); public

DeflaterOutputStream (java.io.OutputStream

out , Deflater

def , int

size ); // Public Instance Methods public void

finish ( ) throws java.io.IOException; // Public Methods Overriding FilterOutputStream public void

close ( ) throws java.io.IOException; public void

write (int

b ) throws java.io.IOException; public void

write (byte[ ]

b , int

off , int

len ) throws java.io.IOException; // Protected Instance Methods protected void

deflate ( ) throws java.io.IOException; // Protected Instance Fields protected byte[ ]

buf ; protected Deflater

def ; }

Subclasses

GZIPOutputStream, ZipOutputStream