java 代码
- package com.wide.cabaret.utils;
- public class Html{
- public Html(){
- super();
- }
- public String toHtml(String str){
- if (str==null){
- return "";
- }else{
- str=str.replaceAll("<", "<");
- str=str.replaceAll(">", ">");
- str=str.replaceAll("'", "''");
- str=str.replaceAll(" ", " ");
- str=str.replaceAll("\n", "<br>");
- }
- return str;
- }
- public String toText(String str){
- if (str==null){
- return "";
- }else{
- str=str.replaceAll("<", "<");
- str=str.replaceAll(">", ">");
- str=str.replaceAll("''", "'");
- str=str.replaceAll(" ", " ");
- str=str.replaceAll("<br>", "\n");
- }
- return str;
- }
- }