private String renderLogFileContents ( String fileName ) throws IOException { FileBackedStringBuffer buffer = new FileBackedStringBuffer ( ) ; int index = retrieveIndexValueFromFileName ( fileName ) ; int runningIndex = 0 ; File eachFile = null ; while ( ( eachFile = retrieveFileFromLogsFolder ( Integer . toString ( runningIndex ) ) ) != null && ( runningIndex <= index ) ) { BufferedReader reader = new BufferedReader ( new FileReader ( eachFile ) ) ; String line = "" ; buffer . append ( "<pre>" ) ; while ( ( line = reader . readLine ( ) ) != null ) { buffer . append ( "<br>" ) . append ( line ) . append ( "</br>" ) ; } buffer . append ( "</pre>" ) ; reader . close ( ) ; runningIndex ++ ; } return buffer . toString ( ) ; }
This method read the content of the file and append into FileBackedStringBuffer