一个方法,改改就可以用  //convertString method:change the special characters
  public String convertString(String strProcessString,String strType){ int intIndex = 0;
char chrChar ;
StringBuffer sbString;

if (strProcessString == null || strProcessString.equals("")) 
return "无";

sbString = new StringBuffer(strProcessString);

while (intIndex < sbString.length()) {
    
    chrChar = sbString.charAt(intIndex); if(strType.equalsIgnoreCase("save") || strType.equalsIgnoreCase("search")){
    
    if (chrChar == '\'') {
         sbString.replace(intIndex, intIndex+1, "''");
         intIndex += 2;
         continue;
    }     if (chrChar == '"') {
         sbString.replace(intIndex, intIndex+1, "&quot;");
         intIndex += 5;
         continue;
    }

    
  if(strType.equalsIgnoreCase("search")){
    if (chrChar == '_') {
        sbString.replace(intIndex, intIndex+1, "[_]");
        intIndex += 3;
        continue;
    }
    if (chrChar == '%') {
        sbString.replace(intIndex, intIndex+1, "[%]");
        intIndex += 3;
        continue;
    }
    if (chrChar == '\\') {
        sbString.replace(intIndex, intIndex+1, "[\\]");
        intIndex += 3;
        continue;
    }
    if (chrChar == '\'') {
        sbString.replace(intIndex, intIndex+1, "\'\'");
        intIndex += 4;
        continue;
    }
}
}
else if(strType.equalsIgnoreCase("body") || strType.equalsIgnoreCase("space")){     if (chrChar == '\n') {
        sbString.replace(intIndex, intIndex+1, "<br>");
        intIndex += 4;
        continue;
    }
    if (chrChar == '<') {
        sbString.replace(intIndex, intIndex+1, "&lt;");
        intIndex += 4;
        continue;
    }

    if (chrChar == '>') {
        sbString.replace(intIndex, intIndex+1, "&gt;");
        intIndex += 4;
        continue;
    }

  if(strType.equalsIgnoreCase("space")){     if (chrChar == ' ') {
         sbString.replace(intIndex, intIndex+1, "&nbsp;");
         intIndex += 5;
         continue;
    }
 
  }
 
  }
else if(strType.equalsIgnoreCase("text")){     if (chrChar == '"') {
         sbString.replace(intIndex, intIndex+1, "&quot;");
         intIndex += 5;
         continue;
    }
}

    intIndex++;
}
return sbString.toString();  }