you're comparing if the two strings are the samereference not same "value" try s.equals(contentFlag)that should give you your desired bahaviour.