This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Well, nobody is going to write that code for you, nor should they. Beside the fact that JavaRanch is NotACodeMill (<- click) this sort of thing is very important to master yourself. Especially considering the forum you posted this in. If you take a look at the String API, under Method Summary, you should be able to find a method that will allow you to do what you're looking for. Let's start by identifying that method.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.