1 5 package org.exoplatform.commons.utils; 6 7 14 public class HtmlUtil { 15 16 static public String showXmlTags(String s) { 17 char[] buf = s.toCharArray() ; 18 StringBuffer b = new StringBuffer () ; 19 for (int i = 0; i < buf.length; i++) { 20 if(buf[i] == '<') { 21 b.append("<") ; 22 } else if (buf[i] == '>') { 23 b.append(">") ; 24 } else { 25 b.append(buf[i]) ; 26 } 27 } 28 return b.toString() ; 29 } 30 31 static public String convertNewLineToBR(String s) { 32 if(s == null) return "" ; 33 char[] buf = s.toCharArray() ; 34 StringBuffer b = new StringBuffer () ; 35 for (int i = 0; i < buf.length; i++) { 36 if(buf[i] == '\n') { 37 b.append("<br/>") ; 38 } else { 39 b.append(buf[i]) ; 40 } 41 } 42 return b.toString() ; 43 } 44 } | Popular Tags |