参考代码如下(该文章参考自https://blog.csdn.net/chenfeng0104/article/details/83533542):
String str = "<html><body><font id=\"test\"><hr>测试123456<br></font><font>78910</font><input id=\"id\"/>XXX</body></html>";
String str1 = "<html><body><font id=\"test\">测试123456</font><font>78910</font><input id=\"id\"/>XXX</body></html>";
str = str.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>","");
System.out.println("去除开始标签以及没有结束标签的标签---" + str);
str = str.replaceAll("</[a-zA-Z]+[1-9]?>","");
System.out.println("去除结束标签---" + str);
str1 = str1.replaceAll("\\&[a-zA-Z]{1,10};","").replaceAll("<[a-zA-Z]+[1-9]?[^><]*>","").replaceAll("</[a-zA-Z]+[1-9]?>","");
System.out.println("去除html标签---" + str);
运行结果: