Exemplo n.º 1
0
 public RecordInputStream(InputStream in) throws RecordFormatException {
   this.in = in;
   try {
     nextSid = LittleEndian.readShort(in);
     // Dont increment the pos just yet (technically we are at the start of
     // the record stream until nextRecord is called).
   } catch (IOException ex) {
     throw new RecordFormatException("Error reading bytes", ex);
   }
 }
Exemplo n.º 2
0
  /**
   * Moves to the next record in the stream.
   *
   * <p><i>Note: The auto continue flag is reset to true</i>
   */
  public void nextRecord() throws RecordFormatException {
    if ((currentLength != -1) && (currentLength != recordOffset)) {
      System.out.println(
          "WARN. Unread " + remaining() + " bytes of record 0x" + Integer.toHexString(currentSid));
    }
    currentSid = nextSid;
    pos += LittleEndian.SHORT_SIZE;
    autoContinue = true;
    try {
      recordOffset = 0;
      currentLength = LittleEndian.readShort(in);
      if (currentLength > MAX_RECORD_DATA_SIZE)
        throw new RecordFormatException(
            "The content of an excel record cannot exceed " + MAX_RECORD_DATA_SIZE + " bytes");
      pos += LittleEndian.SHORT_SIZE;
      in.read(data, 0, currentLength);

      // Read the Sid of the next record
      nextSid = LittleEndian.readShort(in);
    } catch (IOException ex) {
      throw new RecordFormatException("Error reading bytes", ex);
    }
  }