Android examples for java.lang:String HTML
add P Tags to replace <br>
import android.text.Html; import android.text.TextUtils; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main{ public static String addPTags(String source) { String[] asploded = source.split("\n\n"); if (asploded.length > 0) { StringBuilder wrappedHTML = new StringBuilder(); for (int i = 0; i < asploded.length; i++) { String trimmed = asploded[i].trim(); if (trimmed.length() > 0) { trimmed = trimmed.replace("<br />", "<br>") .replace("<br/>", "<br>") .replace("<br>\n", "<br>") .replace("\n", "<br>"); wrappedHTML.append("<p>"); wrappedHTML.append(trimmed); wrappedHTML.append("</p>"); }//from w w w . j a v a 2 s . co m } return wrappedHTML.toString(); } else { return source; } } }