你要自己编一个程序,把字符串中的'/n'变成<br>

解决方案 »

  1.   

    你可以参考一下我写的程序:
    public String getStrbate(String tmp)
    {
      int SPos = 0;
      int EPos = 0;
      int countTotal = tmp.length();
      String strMid = "";
      String strEnd = "";
      for (EPos=0;EPos<countTotal;EPos++){
        char c = tmp.charAt(EPos);
        if (c==13){
          if (SPos!=EPos){
            strMid = tmp.substring(SPos,EPos);
            strEnd = strEnd + strMid + "<br>";
          }else{
            strEnd = strEnd + "<br>";
          }
          SPos = EPos + 2;
        }
      }
      if (SPos<countTotal){
        strMid = tmp.substring(SPos,EPos);
        strEnd = strEnd + strMid + "<br>";
      }
      return strEnd;
    }