@ Override public List < MonitorLine > getLinesFrom ( Object actual ) throws Exception { //TODO Enhance line retrieve to get last lines directly String line ; Integer currentLineNo = 0 ; final List < MonitorLine > result = new ArrayList < MonitorLine > ( ) ; BufferedReader in = null ; try { in = new BufferedReader ( new FileReader ( getFilename ( ) ) ) ; Integer startLine = ( actual == null ) ? 0 : ( Integer ) actual ; //read to startLine while ( currentLineNo < startLine + 1 ) { if ( in . readLine ( ) == null ) { throw new IOException ( "File too small" ) ; } currentLineNo ++ ; } //read until endLine line = in . readLine ( ) ; while ( line != null ) { result . add ( new MonitorLine ( currentLineNo , line ) ) ; currentLineNo ++ ; line = in . readLine ( ) ; } } finally { try { if ( in != null ) { in . close ( ) ; } } catch ( IOException ignore ) { } } return result ; }
Get the file lines since the actual until the last .