/** * Resets the input stream to the beginning by pointing the buffer offset to the beginning of the * available data buffer. * * @throws UnrecoverableIOException * when the available buffer size has been exceeded, in which case the input stream data cannot * be repeated. */ @Override public void reset() throws IOException { if (bytesReadPastMark <= bufferSize) { if (log.isDebugEnabled()) { log.debug("Reset after reading " + bytesReadPastMark + " bytes."); } bufferOffset = 0; } else { throw new UnrecoverableIOException( "Input stream cannot be reset as " + this.bytesReadPastMark + " bytes have been written, exceeding the available buffer size of " + this.bufferSize); } }
/** * Resets the input stream to the beginning by pointing the buffer offset to the beginning of the * available data buffer. * * @throws UnrecoverableIOException * when the available buffer size has been exceeded, in which case the input stream data cannot * be repeated. */ @Override public void reset() throws IOException { if (bytesReadPastMark <= bufferSize) { if (log.isDebugEnabled()) { log.debug("Reset after reading " + bytesReadPastMark + " bytes."); } bufferOffset = 0; } else { throw new UnrecoverableIOException( "Input stream cannot be reset as " + this.bytesReadPastMark + " bytes have been written, exceeding the available buffer size of " + this.bufferSize); } }
private void maybeInterruptInputStream() throws IOException { if (interrupted) { if (log.isDebugEnabled()) { log.debug("Input stream interrupted, closing underlying input stream " + this.inputStream.getClass()); } try { close(); } catch (IOException ioe) { if (log.isWarnEnabled()) { log.warn("Unable to close underlying InputStream on interrupt"); } } // Throw an unrecoverable exception to indicate that this exception was deliberate, and // should not be recovered from. throw new UnrecoverableIOException("Reading from input stream deliberately interrupted"); } }
private void maybeInterruptInputStream() throws IOException { if (interrupted) { if (log.isDebugEnabled()) { log.debug("Input stream interrupted, closing underlying input stream " + this.inputStream.getClass()); } try { close(); } catch (IOException ioe) { if (log.isWarnEnabled()) { log.warn("Unable to close underlying InputStream on interrupt"); } } // Throw an unrecoverable exception to indicate that this exception was deliberate, and // should not be recovered from. throw new UnrecoverableIOException("Reading from input stream deliberately interrupted"); } }
/** * Resets the input stream to the last mark point, or the beginning of the stream if * there is no mark point, by creating a new FileInputStream based on the * underlying file. * * @throws UnrecoverableIOException * when the FileInputStream cannot be re-created. */ @Override public void reset() throws IOException { try { this.fis.close(); this.fis = new FileInputStream(file); long skipped = 0; long toSkip = markPoint; while (toSkip > 0) { skipped = skip(toSkip); toSkip -= skipped; } if (log.isDebugEnabled()) { log.debug("Reset to mark point " + markPoint + " after returning " + bytesReadPastMarkPoint + " bytes"); } this.bytesReadPastMarkPoint = 0; } catch (IOException e) { throw new UnrecoverableIOException("Input stream is not repeatable: " + e.getMessage()); } }
/** * Resets the input stream to the last mark point, or the beginning of the stream if * there is no mark point, by creating a new FileInputStream based on the * underlying file. * * @throws UnrecoverableIOException * when the FileInputStream cannot be re-created. */ @Override public void reset() throws IOException { try { this.fis.close(); this.fis = new FileInputStream(file); long skipped = 0; long toSkip = markPoint; while (toSkip > 0) { skipped = skip(toSkip); toSkip -= skipped; } if (log.isDebugEnabled()) { log.debug("Reset to mark point " + markPoint + " after returning " + bytesReadPastMarkPoint + " bytes"); } this.bytesReadPastMarkPoint = 0; } catch (IOException e) { throw new UnrecoverableIOException("Input stream is not repeatable: " + e.getMessage()); } }