posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          wap 文本展現(xiàn) 簡單替換

          Posted on 2008-06-04 17:19 G_G 閱讀(237) 評論(0)  編輯  收藏 所屬分類: javaGeneral


          ???? public ? static ?String?filter(String?input)?{
          ????????
          if ?(input? == ? null )?{
          ????????????
          return ? null ;
          ????????}
          ????????StringReader?stringReader?
          = ? new ?StringReader(input);
          ????????BufferedReader?reader?
          = ? new ?BufferedReader(stringReader);

          ????????StringBuffer?ret?
          = ? new ?StringBuffer(input.length()? + ? 200 ); // ?add?more?room?to?the?result?String

          ????????String?line?
          = ? null ;
          ????????
          try ?{
          ??? ?? ?? ? //換行后添加<br/>
          ????????????
          while ?((line? = ?reader.readLine())? != ? null )?{
          ??? ?? ?? ?? ?? //wap 對 <? >的替換
          ????????????????ret.append(line.replaceAll(
          " < " ,? " &lt; " ).replaceAll( " > " ,? " &gt; " ). replaceAll( "&",?"&amp;" ) ).append( " <br/>&nbsp;&nbsp; " );
          ????????????}
          // while
          ????????????
          // 如果是最后一行
          ????????}? catch ?(IOException?ex)?{}

          ???????
          return ? " &nbsp;&nbsp; " + ret.toString()?;

          ????}

          ????

          主站蜘蛛池模板: 兖州市| 佛坪县| 江川县| 尖扎县| 宜良县| 依兰县| 菏泽市| 儋州市| 宜兰市| 张北县| 新巴尔虎左旗| 漳浦县| 鄱阳县| 南汇区| 绍兴市| 武安市| 刚察县| 拉萨市| 绿春县| 黄石市| 七台河市| 宁城县| 雷波县| 宁安市| 绿春县| 邵武市| 会宁县| 都江堰市| 中西区| 三穗县| 建昌县| 革吉县| 东乌| 大田县| 林周县| 错那县| 且末县| 平泉县| 玛多县| 潮安县| 青龙|