private int countOccurences(String prefix,String message){
  File f=new File("consolemanagertest.log");
  f.deleteOnExit();
  int count=0;
  BufferedReader br;
  try {
    br=new BufferedReader(new FileReader(f));
    String line=null;
    while ((line=br.readLine()) != null) {
      if (line.startsWith(prefix) && line.endsWith(message)) {
        count++;
      }
    }
    br.close();
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  return count;
}

private int countOccurences ( String prefix , String message ) { File f = new File ( "consolemanagertest.log" ) ; f . deleteOnExit ( ) ; int count = 0 ; BufferedReader br ; try { br = new BufferedReader ( new FileReader ( f ) ) ; String line = null ; while ( ( line = br . readLine ( ) ) != null ) { if ( line . startsWith ( prefix ) && line . endsWith ( message ) ) { count ++ ; } } br . close ( ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return count ; }
count occurrences of strings in the log file .
