public static String extractHtml(String content, String startpoint, String endpoint) {

        /** Regex that matches a start body tag. */
        Pattern startPattern = Pattern.compile(startpoint, Pattern.CASE_INSENSITIVE);

        /** Regex that matches an end body tag. */
        Pattern endPattern = Pattern.compile(endpoint, Pattern.CASE_INSENSITIVE);

        Matcher startMatcher = startPattern.matcher(content);
        Matcher endMatcher = endPattern.matcher(content);

        int start = 0;
        int end = content.length();

        if (startMatcher.find()) {
            start = startMatcher.end();
        }

        if (endMatcher.find(start)) {
            end = endMatcher.start();
        }

        return content.substring(start, end);
    }
public static String extractHtml ( String content , String startpoint , String endpoint ) { Pattern startPattern = Pattern . compile ( startpoint , Pattern . CASE_INSENSITIVE ) ; Pattern endPattern = Pattern . compile ( endpoint , Pattern . CASE_INSENSITIVE ) ; Matcher startMatcher = startPattern . matcher ( content ) ; Matcher endMatcher = endPattern . matcher ( content ) ; int start = 0 ; int end = content . length ( ) ; if ( startMatcher . find ( ) ) { start = startMatcher . end ( ) ; } if ( endMatcher . find ( start ) ) { end = endMatcher . start ( ) ; } return content . substring ( start , end ) ; }
Extracts the content of a HTML page.<p>

This method should be pretty robust and work even if the input HTML does not contains
the specified matchers.<p>

@param content the content to extract the body from
@param startpoint the point where matching starts
@param endpoint the point where matching ends
@return the extracted body tag content