private void resizeWindowIfNecessary ( int newSize ) { try { int numberOfLinesToLoad = newSize - this . lineQueue . size ( ) ; for ( int i = 0 ; i < numberOfLinesToLoad ; i ++ ) { String nextLine = getNextLine ( ) ; if ( nextLine != null ) { lineQueue . addLast ( nextLine ) ; } else { throw new IndexOutOfBoundsException ( "End of stream has been reached!" ) ; } } } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Resizes the sliding window to the given size if necessary .