Unless you use java.util.regex.Pattern, this is what you'd have to do. You could possibly also try java.lang.String.split(). If you want to go with what you've got, what you need to do is to restart your search for a name-breaking character (space? dot?) from the point you last found one. There's another method called indexOf in java.lang.String which allows you to start indexOf from a specified point in the string. You saved the last position of a space in 'space1'. I reckon you'll work the rest out for yourself!