1 22 23 package org.xquark.servlet.util; 24 25 import java.util.StringTokenizer ; 26 27 public class HTML { 28 29 public static String format(String input) { 30 input = replace(input, "<", "<"); 31 input = replace(input, ">", ">"); 32 input = replace(input, "\"", """); 33 return input; 34 } 35 36 public static String replace(String input, String old, String replace) { 37 38 if (input.length() == 0) return input; 39 StringTokenizer tokens = new StringTokenizer (input, old); 40 41 StringBuffer buf = new StringBuffer (); 42 43 if(input.startsWith(old)) 45 buf.append(replace); 46 47 while(tokens.hasMoreTokens()) { 48 buf.append(tokens.nextToken()+replace); 49 } 50 if (!input.endsWith(old)) buf.setLength(buf.length()-replace.length()); 51 return buf.toString(); 52 } 53 } 54 | Popular Tags |