Here you can find the source of htmlNewline(String text)
Parameter | Description |
---|---|
text | the text to substitute. |
public static String htmlNewline(String text)
//package com.java2s; public class Main { /**//from www . j a va 2 s .com * Replaces common newline characters like \n, \r, \r\n to the HTML line * break tag br. * * @param text the text to substitute. * @return the substituted text. */ public static String htmlNewline(String text) { if (text == null || text.trim().isEmpty()) { return null; } return text.replaceAll("(\n|\r|\r\n)", "<br>"); } }