public String getLastNonDashLine ( String backText ) { BufferedReader breader = new BufferedReader ( new StringReader ( backText ) ) ; String last = "" ; String line = null ; try { while ( ( line = breader . readLine ( ) ) != null ) { // there may be blank lines, so we trim first line = line . trim ( ) ; // only if the line has text do we set last to it if ( line . length ( ) > 0 && ! line . startsWith ( "-" ) ) { last = line ; } } } catch ( IOException e ) { DroolsEclipsePlugin . log ( e ) ; } if ( last . indexOf ( "(" ) > - 1 && ! last . endsWith ( ")" ) ) { last = last . substring ( 0 , last . indexOf ( "(" ) ) ; } else if ( last . indexOf ( "(" ) > - 1 && last . endsWith ( ")" ) ) { last = "" ; } return last ; }
Returns the last line that doesn t start with a dash