synchedit.java~4~

来自「他提供是针对特殊HTML字符转换的编辑器.(开发环境JBUILDER2005)」· JAVA~4~ 代码 · 共 28 行

JAVA~4~
28
字号
package editor;
public class SynchEdit
{
  public static String encode2HTML(String str)
  {
    if(null == str || "".equals(str.trim())){
      return str;
    }
    else{
      String html = str;
      html = html.replaceAll("&","&");
      html = html.replaceAll("<","&lt;");
      html = html.replaceAll(">","&gt;");
      html = html.replaceAll("\r\n","\n");
      html = html.replaceAll("\n","<br>");
      html = html.replaceAll("\t","    ");
      html = html.replaceAll(" ","&nbsp;");
      html = html.replaceAll("\"","&quot;");
      return html;
    }
  }

  public static void main(String[] args)
  {
     System.out.println(""+SynchEdit.encode2HTML("<> "));
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?