📄 text.java
字号:
package library;
public class Text {
public Text(){}
public static String elideText(String text,int maxLength)
{
if(text!=null&&text.length()>maxLength)
{
return text.substring(0,maxLength)+"……";
}
else
{
return text;
}
}
public static String textToHtml(String text)
{
if (text == null || text.equals(""))
{
return "";
}
text = text.replaceAll("&", "&");
text = text.replaceAll("<", "<");
text = text.replaceAll(">", ">");
text = text.replaceAll(" ", " ");
text = text.replaceAll("\n", "<br>");
text = text.replaceAll("'", "’");
text = text.replaceAll("\"",""");
text = text.replaceAll("\"",""");
return text;
}
public static String htmlToText(String html)
{
if (html == null || html.equals(""))
{
return "";
}
html = html.replaceAll( "&","&");
html = html.replaceAll( "<","<");
html = html.replaceAll( ">",">");
html = html.replaceAll( " "," ");
html = html.replaceAll( "<br>","\n");
html = html.replaceAll( "’","'");
html = html.replaceAll( ""","\"");
html = html.replaceAll(""","\"");
return html;
}
public static String getFileName(String path)
{
path=path.replaceAll("/","\\\\");
int temp=path.lastIndexOf('\\');
return path.substring(temp+1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -