0

我收到来自 Web 服务的响应,如下所示:

response = (SoapPrimitive) envelope.getResponse();
String result =  response.toString();

“结果”是一个长字符串,由“CredentialAccepted</>FirstName</>LastName</>Picture”组成。我需要在标签</ >处拆分这个结果。我尝试了以下但黑莓不支持。有什么帮助吗?

List<String> list_result = Arrays.asList(result.split("</>"));
4

1 回答 1

3

像这样的东西:

    public static String[] split(String original, String separator) {
        Vector nodes = new Vector();

        String trimmed = original.trim();

        int start = 0;
        int end;
        while ((end = trimmed.indexOf(separator, start)) != -1) {
            nodes.addElement(trimmed.substring(start, end));
            start = end + separator.length();
        }

        if (start < trimmed.length()) {
            nodes.addElement(trimmed.substring(start));
        }

        String[] result = new String[nodes.size()];
        nodes.copyInto(result);

        return result;
    }
于 2012-07-05T12:15:37.507 回答