Q:

String[] strings = TextUtils.split(line, "-");

i am experimenting with the dictionary sample app that comes with the android eclipse plugin. I'm trying to create a directory of local business'. my issue is this section of code.
try {
    String line;

    while((line = reader.readLine()) != null) {
        String[] strings = TextUtils.split(line, "-");
        if (strings.length < 2) continue;
            addWord(strings[0].trim(), strings[1].trim());
        }
    } finally {
        reader.close();
    }
    mLoaded = true;
}

this code allows me to split a line into 2 strings the first being anything before the the hyphen and the second string anything after the hyphen. I am trying to use similar code but i want to break it down into about 3 strings as apposed to 2
thanks for the help

A:

Split() method will split string depending upon what expression you want to split it with
For example: in you case you want to split using "-"
string "abcd-xyz" will be split to "abcd" and "xyz"
string "abcd-xyz-1234" will be split to "abcd" , "xyz" and "1234"
it really depends upon the string you are passing in.

A:

The string you pass to .split is actually regex, so you can split on more than one character with something like (eg if your other split point was a comma)
String[] strings = TextUtils.split(line, ",|\\-");

It will split the string on any place it matches.
http://docs.oracle.com/javase/tutorial/java/data/manipstrings.html

