I have already written code which does the same. Just wanted to find a better way to do it.So i could know where I could improve. This aint any school assignment either.
OK, thanks for clarifying that. I'm sure you can understand how it looked from your first post.
Anyway, your recursive method is cunning, but could be more understandably coded as a simple loop. You could also add the parsed-out words directly to a result String or StringBuilder without the need for the ArrayList. So I agree with stultuske, this could be a whole lot simpler.