Here you can find the source of splitBreaks(String text)
Parameter | Description |
---|---|
text | The HTML String to pass in. (hint: use JSoup's .html() method). |
public static String[] splitBreaks(String text)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; public class Main { /**/*from www. j a va 2 s .co m*/ * Splits a String with HTML in it into paragrpahs, based on the <br> tags found. * Discards empty lines. * * @param text The HTML String to pass in. (hint: use JSoup's .html() method). * @return A list of paragrpahs in the text. HTML is preserved. */ public static String[] splitBreaks(String text) { //split on <br> tags String[] subs = text.split("<br>"); ArrayList<String> a = new ArrayList<>(); //trim empty lines for (String sub : subs) { if (!sub.trim().isEmpty()) { a.add(sub); } } return a.toArray(new String[0]); } }