📄 codefilter.java
字号:
package com.ntsky.common;
public class CodeFilter
{
public CodeFilter()
{
}
public static String toHtml(String s)
{
if(s == null){
s = "";
return s;
} else{
s = Replace(s.trim(), "&", "&");
s = Replace(s.trim(), "<", "<");
s = Replace(s.trim(), ">", ">");
s = Replace(s.trim(), "\t", " ");
s = Replace(s.trim(), "\r\n", "\n");
s = Replace(s.trim(), "\n", "<br>");
s = Replace(s.trim(), " ", " ");
s = Replace(s.trim(), "'", "'");
s = Replace(s.trim(), "\\", "\");
return s;
}
}
public static String toUbbHtml(String s)
{
if(s == null)
{
s = "";
return s;
} else
{
s = Replace(s, "<br>", "\n");
s = Replace(s, "&", "&");
s = Replace(s, " ", " ");
s = Replace(s, "'", "'");
s = Replace(s, "\", "\\");
return s;
}
}
public static String unHtml(String s)
{
s = Replace(s, "<br>", "\n");
s = Replace(s, " ", " ");
return s;
}
public static String Replace(String source, String oldString, String newString)
{
StringBuffer output = new StringBuffer();
int lengthOfsource = source.length();
int lengthOfold = oldString.length();
int posStart;
int i;
for(posStart = 0; (i = source.indexOf(oldString, posStart)) >= 0; posStart = i + lengthOfold)
{
output.append(source.substring(posStart, i));
output.append(newString);
}
if(posStart < lengthOfsource)
output.append(source.substring(posStart));
return output.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -