Look at the API doc for the String class. There are methods in the String class that will solve your problem.