/** * Stops the tailer with an exception * @param e The exception to send to listener */ private void stop(final Exception e) { listener.handle(e); stop(); }
/** * Read new lines. * * @param reader The file to read * @return The new position after the lines have been read * @throws java.io.IOException if an I/O error occurs. */ private long readLines(RandomAccessFile reader) throws IOException { long pos = reader.getFilePointer(); String line = readLine(reader); while (line != null) { pos = reader.getFilePointer(); listener.handle(line); line = readLine(reader); } reader.seek(pos); // Ensure we can re-read if necessary return pos; }
/** * Follows changes in the file, calling the TailerListener's handle method for each new line. */ @Override public void run() { RandomAccessFile reader = null; try { reader = this.initializeReader(reader); reader = this.tailFile(reader); } catch (Exception e) { this.listener.handle(e); } finally { IOUtils.closeQuietly(reader); } }
listener.handle(e);
listener.handle(e);
readLines(save); } catch (IOException ioe) { listener.handle(ioe);