check if string is palindrome in java using string buffer