java.util.zip

Class DeflaterOutputStream

Implemented Interfaces:
Closeable, Flushable
Known Direct Subclasses:
GZIPOutputStream, ZipOutputStream

public class DeflaterOutputStream
extends FilterOutputStream

This class implements an output stream filter for compressing data in the "deflate" compression format. It is also used as the basis for other types of compression filters, such as GZIPOutputStream.
See Also:
Deflater

Field Summary

protected byte[]
buf
Output buffer for writing compressed data.
protected Deflater
def
Compressor for this stream.

Fields inherited from class java.io.FilterOutputStream

out

Constructor Summary

DeflaterOutputStream(OutputStream out)
Creates a new output stream with a default compressor and buffer size.
DeflaterOutputStream(OutputStream out, Deflater def)
Creates a new output stream with the specified compressor and a default buffer size.
DeflaterOutputStream(OutputStream out, Deflater def, int size)
Creates a new output stream with the specified compressor and buffer size.

Method Summary

void
close()
Writes remaining compressed data to the output stream and closes the underlying stream.
protected void
deflate()
Writes next block of compressed data to the output stream.
void
finish()
Finishes writing compressed data to the output stream without closing the underlying stream.
void
write(byte[] b, int off, int len)
Writes an array of bytes to the compressed output stream.
void
write(int b)
Writes a byte to the compressed output stream.

Methods inherited from class java.io.FilterOutputStream

close, flush, write, write, write

Methods inherited from class java.io.OutputStream

close, flush, write, write, write

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

buf

protected byte[] buf
Output buffer for writing compressed data.

def

protected Deflater def
Compressor for this stream.

Constructor Details

DeflaterOutputStream

public DeflaterOutputStream(OutputStream out)
Creates a new output stream with a default compressor and buffer size.
Parameters:
out - the output stream
Usages and Demos :

View More Examples of DeflaterOutputStream(OutputStream out)
   1:     ByteArrayOutputStream buf = new ByteArrayOutputStream(1024);
   2:     DeflaterOutputStream dout = new DeflaterOutputStream(buf);
   3:     DataOutputStream out2 = new DataOutputStream(dout);
   4:     for (Iterator it = entries.iterator(); it.hasNext();)
   5:       ((Entry) it.next()).encode(out2);

View Full Code Here
   1:             {
   2:                 out.setFilterStream(new java.util.zip.DeflaterOutputStream(out.getFilterStream()));
   3:             }
   4:             else if (!"identity".equalsIgnoreCase(coding))
   5:                 throw new HttpException(HttpResponse.__501_Not_Implemented,

View Full Code Here
   1:     if (ct.equalsIgnoreCase(CompressionResWrapper.DEFLATE)) {
   2:       ops = new DeflaterOutputStream(ba);
   3:     }
   4: 

View Full Code Here
   1:                 compressed = true;
   2:                 os = new DeflaterOutputStream(os);
   3:             }
   4:             DataOutputStream dataOut = new DataOutputStream(os);
   5:             MarshallingSupport.writeUTF8(dataOut, text);

View Full Code Here
   1:     if (_isAllowCompress) {
   2:       dOut = new DeflaterOutputStream(os);
   3:       os = dOut;
   4:     }

View Full Code Here

DeflaterOutputStream

public DeflaterOutputStream(OutputStream out,
                            Deflater def)
Creates a new output stream with the specified compressor and a default buffer size.
Parameters:
out - the output stream
def - the compressor ("deflater")
Usages and Demos :

View More Examples of DeflaterOutputStream(OutputStream out,Deflater def)
   1:             AsOutputStream base = new AsOutputStream(out);
   2:             DeflaterOutputStream s = new DeflaterOutputStream(base, deflater);
   3:             Copying.copyBits(decoded, s);
   4:             s.flush();
   5:             s.close();

View Full Code Here
   1:     _os = os;
   2:     _out = new DeflaterOutputStream(_os, def);
   3:     
   4:     _os.write(_header, 0, _header.length);
   5:   }

View Full Code Here
   1:         Deflater dfl = new Deflater(Deflater.BEST_SPEED);
   2:         os = new DeflaterOutputStream(os, dfl);
   3:     }
   4:     os = new DataOutputStream(os);
   5:     b.marshal((DataOutputStream)os);

View Full Code Here
   1:         if (deflater!=null) 
   2:             t = new DeflaterOutputStream(t, deflater);
   3:         DataOutputStream out = new DataOutputStream(t);
   4: 
   5:         data.writeExternal(out);

View Full Code Here
   1:         Deflater compresser = new Deflater(9);
   2:         DeflaterOutputStream deflaterStream = new DeflaterOutputStream(byteStream, compresser);
   3: 
   4:         try {
   5:             byte[] buf = new byte[BUFFER_SIZE];

View Full Code Here

DeflaterOutputStream

public DeflaterOutputStream(OutputStream out,
                            Deflater def,
                            int size)
Creates a new output stream with the specified compressor and buffer size.
Parameters:
out - the output stream
def - the compressor ("deflater")
size - the output buffer size
Throws:
IllegalArgumentException - if size is <= 0
Usages and Demos :

View More Examples of DeflaterOutputStream(OutputStream out,Deflater def,int size)
   1:     Deflater def = new Deflater(Deflater.BEST_COMPRESSION, false);
   2:     OutputStream zout = new DeflaterOutputStream(bout, def, 8*1024);
   3:     zout.write(data);
   4:     zout.close();
   5:     def.end();

View Full Code Here

Method Details

close

public void close()
            throws IOException
Writes remaining compressed data to the output stream and closes the underlying stream.
Specified by:
close in interface Closeable
Overrides:
close in interface FilterOutputStream
Throws:
IOException - if an I/O error has occurred
Usages and Demos :

View More Examples of close()
   1: import java.net.URLEncoder;
   2: import java.util.zip.DeflaterOutputStream;
   3: 
   4:         ...
   5:     ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
   6:     DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(
   7:       byteOutputStream);
   8:         ...
   9:     deflaterOutputStream.write(xmlBytes, 0, xmlBytes.length);
  10:     deflaterOutputStream.close();

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.DeflaterOutputStream;
   3: 
   4:         ...
   5:             AsOutputStream base = new AsOutputStream(out);
   6:             DeflaterOutputStream s = new DeflaterOutputStream(base, deflater);
   7:             Copying.copyBits(decoded, s);
   8:         ...
   9:             s.flush();
  10:             s.close();
  11:             out = AsOutputStream.unwrap(base);

View Full Code Here
   1: 
   2:     DeflaterOutputStream dOut = null;
   3: 
   4:         ...
   5:     if (_isAllowCompress) {
   6:       dOut = new DeflaterOutputStream(os);
   7:       os = dOut;
   8:         ...
   9:     } finally {
  10:       in.close();
  11:     }
  12:         ...
  13:     if (dOut != null)
  14:       dOut.close();

View Full Code Here
   1: import java.io.*;
   2: import java.util.zip.DeflaterOutputStream;
   3: import java.util.zip.InflaterInputStream;
   4:         ...
   5:         ByteArrayOutputStream out = new ByteArrayOutputStream();
   6:         DeflaterOutputStream  deflater = new DeflaterOutputStream( out );
   7:         deflater.write(bytes, offset, length);
   8:         ...
   9:         deflater.close();
  10:         return out.toByteArray();

View Full Code Here
   1:     private OutputStream _bodyOut;
   2:     private DeflaterOutputStream _deflateOut;
   3:     
   4:         ...
   5:     
   6:       _deflateOut = new DeflaterOutputStream(_bodyOut);
   7:     }
   8:         ...
   9:       if (out != null) {
  10:     _deflateOut.close();
  11:         ...
  12:     _bodyOut.close();

View Full Code Here

deflate

protected void deflate()
            throws IOException
Writes next block of compressed data to the output stream.
Throws:
IOException - if an I/O error has occurred

finish

public void finish()
            throws IOException
Finishes writing compressed data to the output stream without closing the underlying stream. Use this method when applying multiple filters in succession to the same output stream.
Throws:
IOException - if an I/O error has occurred
Usages and Demos :

View More Examples of finish()
   1: import java.util.Iterator;
   2: import java.util.zip.DeflaterOutputStream;
   3: import java.util.zip.InflaterInputStream;
   4:         ...
   5:     ByteArrayOutputStream buf = new ByteArrayOutputStream(1024);
   6:     DeflaterOutputStream dout = new DeflaterOutputStream(buf);
   7:     DataOutputStream out2 = new DataOutputStream(dout);
   8:         ...
   9:       ((Entry) it.next()).encode(out2);
  10:     dout.finish();
  11:     payload = buf.toByteArray();

View Full Code Here
   1: import java.io.IOException;
   2: import java.util.zip.DeflaterOutputStream;
   3: import java.util.zip.GZIPOutputStream;
   4:         ...
   5: 
   6:   private DeflaterOutputStream ops;
   7: 
   8:         ...
   9:     if (ct.equalsIgnoreCase(CompressionResWrapper.DEFLATE)) {
  10:       ops = new DeflaterOutputStream(ba);
  11:     }
  12:         ...
  13: 
  14:     ops.finish();

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.DeflaterOutputStream;
   3: import java.util.zip.InflaterInputStream;
   4:         ...
   5:       Deflater def = new Deflater (java.util.zip.Deflater.BEST_COMPRESSION);
   6:       DeflaterOutputStream dos = new DeflaterOutputStream (baos, def);
   7:       
   8:         ...
   9:       out.close ();
  10:       dos.finish();
  11:       dos.close ();

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.zip.DeflaterOutputStream;
   3: 
   4:         ...
   5:         } else {
   6:             DeflaterOutputStream out = new DeflaterOutputStream(new OutputStream() {
   7:                 public void write(int b) throws IOException {
   8:         ...
   9:             out.write(src, offset, length);
  10:             out.finish();
  11:             if (buffer.position() >= length) {

View Full Code Here
   1: import java.util.Map;
   2: import java.util.zip.DeflaterOutputStream;
   3: 
   4:         ...
   5:        }
   6:        DeflaterOutputStream deflater = null;
   7:        writeDataset(new DcmStreamHandlerImpl(param.deflated
   8:         ...
   9:            ? deflater = new DeflaterOutputStream(out) : out), param);
  10:        if (deflater != null)
  11:         ...
  12:            deflater.finish();

View Full Code Here

write

public void write(byte[] b,
                  int off,
                  int len)
            throws IOException
Writes an array of bytes to the compressed output stream. This method will block until all the bytes are written.
Parameters:
b - the data to be written
off - the start offset of the data
len - the length of the data
Throws:
IOException - if an I/O error has occurred
Usages and Demos :

View More Examples of write(byte[] b,int off,int len)
   1: import java.net.URLEncoder;
   2: import java.util.zip.DeflaterOutputStream;
   3: 
   4:         ...
   5:     ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
   6:     DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(
   7:       byteOutputStream);
   8:         ...
   9:     deflaterOutputStream.write(xmlBytes, 0, xmlBytes.length);
  10:     deflaterOutputStream.close();

View Full Code Here
   1: import java.io.IOException;
   2: import java.util.zip.DeflaterOutputStream;
   3: import java.util.zip.GZIPOutputStream;
   4:         ...
   5: 
   6:   private DeflaterOutputStream ops;
   7: 
   8:         ...
   9:     if (ct.equalsIgnoreCase(CompressionResWrapper.DEFLATE)) {
  10:       ops = new DeflaterOutputStream(ba);
  11:     }
  12:         ...
  13: 
  14:     ops.write(bytes, o, leng);

View Full Code Here
   1: import java.io.*;
   2: import java.util.zip.DeflaterOutputStream;
   3: import java.util.zip.InflaterInputStream;
   4:         ...
   5:         ByteArrayOutputStream out = new ByteArrayOutputStream();
   6:         DeflaterOutputStream  deflater = new DeflaterOutputStream( out );
   7:         ...
   8:         deflater.write(bytes, offset, length);
   9:         deflater.close();

View Full Code Here
   1:     private OutputStream _bodyOut;
   2:     private DeflaterOutputStream _deflateOut;
   3:     
   4:         ...
   5:     
   6:       _deflateOut = new DeflaterOutputStream(_bodyOut);
   7:     }
   8:         ...
   9:     {
  10:       _deflateOut.write(buffer, offset, length);
  11:     }

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.DeflaterOutputStream;
   3: 
   4:         ...
   5:   private OutputStream _os;
   6:   private DeflaterOutputStream _out;
   7:   private CRC32 _crc32;
   8:         ...
   9:     _os = os;
  10:     _out = new DeflaterOutputStream(_os, def);
  11:     
  12:         ...
  13:     _os.write(_header, 0, _header.length);

View Full Code Here

write

public void write(int b)
            throws IOException
Writes a byte to the compressed output stream. This method will block until the byte can be written.
Overrides:
write in interface FilterOutputStream
Parameters:
b - the byte to be written
Throws:
IOException - if an I/O error has occurred
Usages and Demos :

View More Examples of write(int b)
   1: import java.io.IOException;
   2: import java.util.zip.DeflaterOutputStream;
   3: import java.util.zip.GZIPOutputStream;
   4:         ...
   5: 
   6:   private DeflaterOutputStream ops;
   7: 
   8:         ...
   9:     if (ct.equalsIgnoreCase(CompressionResWrapper.DEFLATE)) {
  10:       ops = new DeflaterOutputStream(ba);
  11:     }
  12:         ...
  13: 
  14:     ops.write((byte)b);

View Full Code Here
   1: import java.util.Map;
   2: import java.util.zip.DeflaterOutputStream;
   3: 
   4:         ...
   5:             try {
   6:                 g.write(baos);
   7:             } catch (IOException impossible) {
   8:         ...
   9:         ByteArrayOutputStream baos = new ByteArrayOutputStream();
  10:         DeflaterOutputStream dos = new DeflaterOutputStream(baos);
  11:         try {
  12:         ...
  13:                 String ret = "d5:error"+msg.length()+":"+msg+"e";
  14:                 dos.write(ret.getBytes());

View Full Code Here
   1:     private OutputStream _bodyOut;
   2:     private DeflaterOutputStream _deflateOut;
   3:     
   4:         ...
   5:     
   6:       _deflateOut = new DeflaterOutputStream(_bodyOut);
   7:     }
   8:         ...
   9:     {
  10:       _deflateOut.write(ch);
  11:     }

View Full Code Here
   1: import java.util.zip.Deflater;
   2: import java.util.zip.DeflaterOutputStream;
   3: 
   4:         ...
   5:   private OutputStream _os;
   6:   private DeflaterOutputStream _out;
   7:   private CRC32 _crc32;
   8:         ...
   9:     _os = os;
  10:     _out = new DeflaterOutputStream(_os, def);
  11:     
  12:         ...
  13:   {
  14:     _out.write(v);

View Full Code Here
   1: import com.lowagie.text.ExceptionConverter;
   2: import jp.ujihara.java.util.zip.DeflaterOutputStream;
   3: import com.lowagie.text.Document;
   4:         ...
   5:                 ByteArrayOutputStream stream = new ByteArrayOutputStream();
   6:                 DeflaterOutputStream zip = new DeflaterOutputStream(stream);
   7:         ...
   8:                 zip.write(conts);
   9:                 zip.close();
  10:         ...
  11:                 DeflaterOutputStream zip = new DeflaterOutputStream(stream);
  12:                 zip.write(data);

View Full Code Here