⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text.java

📁 一个用java开发的具有搜索功能的图书管理系统
💻 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("<", "&lt;");
		text = text.replaceAll(">", "&gt;");
		text = text.replaceAll("  ", "&nbsp;");
		text = text.replaceAll("\n", "<br>");
		text = text.replaceAll("'", "&rsquo;");
		text = text.replaceAll("\"","&quot;");
		text = text.replaceAll("\"","&quot;");
		return text;
	}
	
	public static String htmlToText(String html)
	{
		if (html == null || html.equals(""))
		{
			return "";
		}
		html = html.replaceAll( "&amp;","&");
		html = html.replaceAll( "&lt;","<");
		html = html.replaceAll( "&gt;",">");
		html = html.replaceAll( "&nbsp;","  ");
		html = html.replaceAll( "<br>","\n");
		html = html.replaceAll( "&rsquo;","'");
		html = html.replaceAll( "&quot;","\"");
		html = html.replaceAll("&quot;","\"");
		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 + -