Java examples for java.lang:String HTML
Escape HTML <Br>
//package com.java2s; public class Main { public static void main(String[] argv) { String original = "java2s.com"; System.out.println(HTMLEscapeBr(original)); }/* w w w .j a v a 2 s . co m*/ public static String HTMLEscapeBr(String original) { if (original == null) return ""; StringBuffer out = new StringBuffer(""); char[] chars = original.toCharArray(); for (int i = 0; i < chars.length; i++) { boolean found = true; switch (chars[i]) { case '\n': out.append("<br/>"); break; //newline case '\r': break; default: found = false; break; } if (!found) out.append(chars[i]); } return out.toString(); } }