CodeEval solutions to find trailing strings
I suggest a functional answer for this problem (In ruby but should easily be translatable into Java):

def endswith(text, appendix)
    text.last(appendix.length) == appendix
end


I did not benchmark but this approach is likely to be faster as you are only using using 2 functions and a comparison instead of all the loops and ifs that you used.