// Problem with StringBuffer.equals or StringBuilder.equals StringBuffer sb = new StringBuffer( 10 ); sb.append( "something" ); if ( sb.equals( "something" ) ) { // this won't print, as you might expect out.println( "match" ); } // Instead you must write: if ( sb.toString().equals( "something" ) ) { // then it will print out.println( "match" ); }