Esempio n. 1
0
 private void readFromBuffer(ByteBuffer buf) throws IOException {
   this.buf = buf;
   buf.order(ByteOrder.LITTLE_ENDIAN);
   header = new Header();
   header.read(buf);
   fixupHeader();
 }
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();
 }
  public int read(DataInputStream istream) throws IOException {
    preRead();
    int retVal = 0;

    // read header
    retVal += header.read(istream);
    // read protocol_version
    {
      protocol_version = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read configuration_count_change
    {
      configuration_count_change = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read resources
    retVal += resources.read(istream);
    // read pvData
    {
      IntegerHolder iHolder = new IntegerHolder();
      DataInputStream disTemp = istream;
      pvData = PVDataFactory.createMsg(protocol_version, disTemp, iHolder);
      retVal += iHolder.getValue();
    }
    // read certificateCount
    {
      certificateCount = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read cvCertificates
    for (int iIdx = 0; iIdx < certificateCount + (0); iIdx++) {
      CVCertificate temp;
      temp = new CVCertificate();
      retVal += temp.read(istream);
      cvCertificates.add(temp);
    }

    postRead();
    return retVal;
  }
Esempio n. 4
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);
    }
  }