61 |
*/ |
*/ |
62 |
protected CRC32 crc; |
protected CRC32 crc; |
63 |
|
|
64 |
/* Creates a GZIPOutputStream with the default buffer size |
/** |
65 |
* |
* Creates a GZIPOutputStream with the default buffer size |
66 |
* |
* |
67 |
* @param out The stream to read data (to be compressed) from |
* @param out The stream to read data (to be compressed) from |
68 |
* |
* |
81 |
public GZIPOutputStream(OutputStream out, int size) throws IOException |
public GZIPOutputStream(OutputStream out, int size) throws IOException |
82 |
{ |
{ |
83 |
super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size); |
super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size); |
|
|
|
84 |
crc = new CRC32(); |
crc = new CRC32(); |
85 |
int mod_time = (int) (System.currentTimeMillis() / 1000L); |
int mod_time = (int) (System.currentTimeMillis() / 1000L); |
86 |
byte[] gzipHeader = |
byte[] gzipHeader = |
109 |
out.write(gzipHeader); |
out.write(gzipHeader); |
110 |
// System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )"); |
// System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )"); |
111 |
} |
} |
112 |
|
|
113 |
public synchronized void write(byte[] buf, int off, int len) |
public synchronized void write(byte[] buf, int off, int len) |
114 |
throws IOException |
throws IOException |
115 |
{ |
{ |
116 |
super.write(buf, off, len); |
super.write(buf, off, len); |
117 |
crc.update(buf, off, len); |
crc.update(buf, off, len); |
118 |
} |
} |
119 |
|
|
120 |
/** Writes remaining compressed output data to the output stream |
/** |
121 |
|
* Writes remaining compressed output data to the output stream |
122 |
* and closes it. |
* and closes it. |
123 |
*/ |
*/ |
124 |
public void close() throws IOException |
public void close() throws IOException |