字符串的比较最好用equals,不要用==

解决方案 »

  1.   

    String replaceAll(String regex, String replacement) 
              Replaces each substring of this string that matches the given regular expression with the given replacement.  String trim() 
              Returns a copy of the string, with leading and trailing whitespace omitted
      

  2.   

    if(temp_sbr.charAt(i)=="\n") ==> if(temp_sbr.charAt(i).equals("\n"))
    {
     ……
    }
    若不行将:
    if(temp_sbr.charAt(i)=="\n") else if(temp_sbr.charAt(i)=="\r")
    改成:
    if(temp_sbr.charAt(i).equals("\r\n"))
    {
      temp_br=temp_br.append("<br>");
    }