从java

时间:2015-12-28 01:04:24

标签: java string http tags entity

我有http正文,我想在其中删除所有图片代码。例如,来自具有实体的响应:

StringEntity entity = new StringEntity(
            "<!DOCTYPE html>\n" +
            "<html>\n" +
                "<head>\n" + 
                    "<meta charset=\"UTF-8\">\n" + 
                    "<title>Title of the document</title>\n" +
                "</head>\n" +
                    "<body>\n"
                    + "Content of the document..\n" +
                        "<img src=\"image\">\n" + 
                    "</body>\n" +
            "</html>");

我尝试了以下但没有改变:

        String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
        responseString.replaceAll("<img .*?>","");

0 个答案:

没有答案