Encode data using ZIP compression
- 引数:
-
| data | byte array to compress |
- 戻り値:
byte[] of zip encoded data
- 例外:
-
| IOException | if fails reading/writing streams |
ZipEncoding.java の 50 行で定義されています。00051 {
00052 ByteArrayInputStream bais = new ByteArrayInputStream(data);
00053 ByteArrayOutputStream baos = new ByteArrayOutputStream();
00054 BufferedOutputStream bos = new BufferedOutputStream(
00055 new DeflaterOutputStream(baos, new Deflater()));
00056 byte[] bdata = new byte[1024];
00057 int byteCount;
00058 while ((byteCount = bais.read(bdata, 0, 1024)) > -1)
00059 {
00060 bos.write(bdata, 0, byteCount);
00061 }
00062 bos.flush();
00063 bos.close();
00064 return baos.toByteArray();
00065 }
|