Esempio n. 1
0
 /**
  * Create packet with given header.
  *
  * @param header Packet header
  */
 public Packet(Header header) {
   if (log.isTraceEnabled()) {
     log.trace("Header: {}", header);
   }
   this.header = header;
   data = IoBuffer.allocate(header.getSize()).setAutoExpand(true);
 }
Esempio n. 2
0
 private byte[] read(byte[] data, int pos) throws IOException {
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   ByteArrayInputStream bis = new ByteArrayInputStream(data);
   Header header = new Header();
   header.read(data, pos);
   bis.skip(pos + header.getSize());
   InflaterInputStream inflater = new InflaterInputStream(bis);
   byte[] chunk = new byte[4096];
   int count;
   while ((count = inflater.read(chunk)) >= 0) {
     out.write(chunk, 0, count);
   }
   inflater.close();
   return out.toByteArray();
 }
Esempio n. 3
0
  @Override
  public byte[] getData() {
    try {
      byte[] rawdata = getRawData();

      ByteArrayOutputStream out = new ByteArrayOutputStream();
      InputStream is = new ByteArrayInputStream(rawdata);
      Header header = new Header();
      header.read(rawdata, CHECKSUM_SIZE);
      is.skip(header.getSize() + CHECKSUM_SIZE);

      InflaterInputStream inflater = new InflaterInputStream(is);
      byte[] chunk = new byte[4096];
      int count;
      while ((count = inflater.read(chunk)) >= 0) {
        out.write(chunk, 0, count);
      }
      inflater.close();
      return out.toByteArray();
    } catch (IOException e) {
      throw new HSLFException(e);
    }
  }
Esempio n. 4
0
 /**
  * Create packet with given header
  *
  * @param header Packet header
  */
 public Packet(Header header) {
   this.header = header;
   data = ByteBuffer.allocate(header.getSize() + (header.getTimer() == 0xffffff ? 4 : 0));
 }