Generate Substring From A String In Java