35 |
obligated to do so. If you do not wish to do so, delete this |
obligated to do so. If you do not wish to do so, delete this |
36 |
exception statement from your version. */ |
exception statement from your version. */ |
37 |
|
|
38 |
|
|
39 |
package java.util.zip; |
package java.util.zip; |
40 |
|
|
|
import java.io.InputStream; |
|
|
import java.io.IOException; |
|
41 |
import java.io.EOFException; |
import java.io.EOFException; |
42 |
|
import java.io.IOException; |
43 |
|
import java.io.InputStream; |
44 |
|
|
45 |
/** |
/** |
46 |
* This filter stream is used to decompress a "GZIP" format stream. |
* This filter stream is used to decompress a "GZIP" format stream. |
56 |
/** |
/** |
57 |
* The magic number found at the start of a GZIP stream. |
* The magic number found at the start of a GZIP stream. |
58 |
*/ |
*/ |
59 |
public static final int GZIP_MAGIC = 0x1f8b; |
public static final int GZIP_MAGIC = 0x8b1f; |
60 |
|
|
61 |
/** |
/** |
62 |
* The mask for bit 0 of the flag byte. |
* The mask for bit 0 of the flag byte. |
198 |
eos = true; |
eos = true; |
199 |
return; |
return; |
200 |
} |
} |
201 |
|
int magic2 = in.read(); |
202 |
|
if ((magic + (magic2 << 8)) != GZIP_MAGIC) |
203 |
|
throw new IOException("Error in GZIP header, bad magic code"); |
204 |
headCRC.update(magic); |
headCRC.update(magic); |
205 |
if (magic != (GZIP_MAGIC >> 8)) |
headCRC.update(magic2); |
|
throw new IOException("Error in GZIP header, first byte doesn't match"); |
|
|
|
|
|
magic = in.read(); |
|
|
if (magic != (GZIP_MAGIC & 0xff)) |
|
|
throw new IOException("Error in GZIP header, second byte doesn't match"); |
|
|
headCRC.update(magic); |
|
206 |
|
|
207 |
/* 2. Check the compression type (must be 8) */ |
/* 2. Check the compression type (must be 8) */ |
208 |
int CM = in.read(); |
int CM = in.read(); |