Пример #1
0
 public static byte[] compress(byte data[], String signature, String version) {
   byte header[] = ArrayUtil.mergeArrays(signature.getBytes(), version.getBytes());
   header = ArrayUtil.mergeArrays(header, Byteconvert.convertBack(data.length));
   byte result[] = ArrayUtil.resizeArray(header, data.length * 2);
   Deflater deflater = new Deflater();
   deflater.setInput(data);
   deflater.finish();
   int clength = deflater.deflate(result, 12, result.length - 12);
   return ArrayUtil.getSubArray(result, 0, clength + 12);
 }
Пример #2
0
 public static byte[] decompress(byte buffer[]) throws IOException {
   byte result[] = new byte[Byteconvert.convertInt(buffer, 8)];
   inflater.setInput(buffer, 12, buffer.length - 12);
   try {
     inflater.inflate(result);
   } catch (DataFormatException e) {
     throw new IOException();
   }
   inflater.reset();
   return result;
 }