/** * Returns an ArchiveRecord iterator. * Of note, on IOException, especially if ZipException reading compressed * ARCs, rather than fail the iteration, try moving to the next record. * If {@link ArchiveReader#strict} is not set, this will usually succeed. * @return An iterator over ARC records. */ public Iterator<ArchiveRecord> iterator() { // Eat up any record outstanding. try { cleanupCurrentRecord(); } catch (IOException e) { throw new RuntimeException(e); } return new ArchiveRecordIterator(); }
/** * Returns an ArchiveRecord iterator. * Of note, on IOException, especially if ZipException reading compressed * ARCs, rather than fail the iteration, try moving to the next record. * If {@link ArchiveReader#strict} is not set, this will usually succeed. * @return An iterator over ARC records. */ public Iterator<ArchiveRecord> iterator() { // Eat up any record outstanding. try { cleanupCurrentRecord(); } catch (IOException e) { throw new RuntimeException(e); } return new ArchiveRecordIterator(); }
/** * Returns an ArchiveRecord iterator. * Of note, on IOException, especially if ZipException reading compressed * ARCs, rather than fail the iteration, try moving to the next record. * If {@link ArchiveReader#strict} is not set, this will usually succeed. * @return An iterator over ARC records. */ public Iterator<ArchiveRecord> iterator() { // Eat up any record outstanding. try { cleanupCurrentRecord(); } catch (IOException e) { throw new RuntimeException(e); } return new ArchiveRecordIterator(); }
/** * Get record at passed <code>offset</code>. * * @param offset Byte index into file at which a record starts. * @return An Archive Record reference. * @throws IOException */ public ArchiveRecord get(long offset) throws IOException { cleanupCurrentRecord(); long posn = positionForRecord(in); if(offset>=posn) { in.skip(offset-posn); } else { throw new UnsupportedOperationException("no reverse seeking: at "+posn+" requested "+offset); } return createArchiveRecord(this.in, offset); }
/** * Get record at passed <code>offset</code>. * * @param offset Byte index into file at which a record starts. * @return An Archive Record reference. * @throws IOException */ public ArchiveRecord get(long offset) throws IOException { cleanupCurrentRecord(); long posn = positionForRecord(in); if(offset>=posn) { in.skip(offset-posn); } else { throw new UnsupportedOperationException("no reverse seeking: at "+posn+" requested "+offset); } return createArchiveRecord(this.in, offset); }
/** * Get record at passed <code>offset</code>. * * @param offset Byte index into file at which a record starts. * @return An Archive Record reference. * @throws IOException */ public ArchiveRecord get(long offset) throws IOException { cleanupCurrentRecord(); long posn = positionForRecord(in); if(offset>=posn) { in.skip(offset-posn); } else { throw new UnsupportedOperationException("no reverse seeking: at "+posn+" requested "+offset); } return createArchiveRecord(this.in, offset); }
/** * @return True if we have more records to read. * @exception RuntimeException Can throw an IOException wrapped in a * RuntimeException if a problem reading underlying stream (Corrupted * gzip, etc.). */ public boolean hasNext() { // Call close on any extant record. This will scoot us past // any content not yet read. try { cleanupCurrentRecord(); } catch (IOException e) { if (isStrict()) { throw new RuntimeException(e); } if (e instanceof EOFException) { logger.warning("Premature EOF cleaning up " + currentRecord.getHeader().toString() + ": " + e.getMessage()); return false; } // If not strict, try going again. We might be able to skip // over the bad record. logger.log(Level.WARNING,"Trying skip of failed record cleanup of " + currentRecord.getHeader().toString() + ": " + e.getMessage(), e); } return innerHasNext(); }
/** * @return True if we have more records to read. * @exception RuntimeException Can throw an IOException wrapped in a * RuntimeException if a problem reading underlying stream (Corrupted * gzip, etc.). */ public boolean hasNext() { // Call close on any extant record. This will scoot us past // any content not yet read. try { cleanupCurrentRecord(); } catch (IOException e) { if (isStrict()) { throw new RuntimeException(e); } if (e instanceof EOFException) { logger.warning("Premature EOF cleaning up " + currentRecord.getHeader().toString() + ": " + e.getMessage()); return false; } // If not strict, try going again. We might be able to skip // over the bad record. logger.log(Level.WARNING,"Trying skip of failed record cleanup of " + currentRecord.getHeader().toString() + ": " + e.getMessage(), e); } return innerHasNext(); }
/** * @return True if we have more records to read. * @exception RuntimeException Can throw an IOException wrapped in a * RuntimeException if a problem reading underlying stream (Corrupted * gzip, etc.). */ public boolean hasNext() { // Call close on any extant record. This will scoot us past // any content not yet read. try { cleanupCurrentRecord(); } catch (IOException e) { if (isStrict()) { throw new RuntimeException(e); } if (e instanceof EOFException) { logger.warning("Premature EOF cleaning up " + currentRecord.getHeader().toString() + ": " + e.getMessage()); return false; } // If not strict, try going again. We might be able to skip // over the bad record. logger.log(Level.WARNING,"Trying skip of failed record cleanup of " + currentRecord.getHeader().toString() + ": " + e.getMessage(), e); } return innerHasNext(); }