尝试拆分黑莓应用程序的服务器响应

时间:2012-07-05 11:51:28

标签: blackberry

我收到来自网络服务的回复如下:

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

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

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

1 个答案:

答案 0 :(得分: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;
    }