如何在没有多个部分的情况下解析MIME

时间:2014-12-30 10:17:21

标签: java mime mime4j

我需要来自java

中以下响应字符串的<xml>__content__</xml>部分
Content-Type: application/xml; charset=UTF-8; name=response_xml<xml>...</xml>

1 个答案:

答案 0 :(得分:0)

编辑


现在,我了解了您的需求,您可以使用简单的regex在标记<xml></xml>

之间提取文字
public static void main(String[] args) {
    String a="Content-Type: application/xml; charset=UTF-8; name=response_xml<xml>content</xml>";
    final Pattern pattern = Pattern.compile("<xml>(.+?)</xml>");
    final Matcher matcher = pattern.matcher(a);
    matcher.find();
    System.out.println(matcher.group(1));
}