Java与给定的单词行分裂有问题

时间:2015-03-02 10:57:15

标签: java string-split

String cityStateZip = ResultSetHelper.getString(resultSet, "line_3_addr"); // PU ABCDEF, CS 12345
if (StringHelper.isValid(cityStateZip)) {
    String[] splited = cityStateZip.split("\\s+");

    if (splited[0].length() > 0) {
        String city = splited[0].substring(0, splited[0].length() - 1);
        super.setFieldValue(OFFICECITY, city);  //PU
    }

    if (splited[1].length() > 0) {
        super.setFieldValue(OFFICEST, splited[1]); //ABCDEF
    }

    if (splited[2].length() > 0 ) {
        super.setFieldValue(OFFICEZIP, splited[2]); // CS 12345
    }
}

0 个答案:

没有答案