过滤Html标签
代码语言:javascript
复制import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
public class HtmlUtil {
/**
*
* @param content
* @return
*/
public final static String cleanHtml(String content) {
if (StringUtils.isBlank(content)) {
return "";
}
content = StringEscapeUtils.unescapeHtml4(content);
content = Jsoup.clean(content, Whitelist.none());
content = StringEscapeUtils.unescapeHtml4(content).replaceAll(" ", "").trim();
content = StringEscapeUtils.unescapeJava(content);
return content;
}
}
读取配置文件
代码语言:javascript
复制public class PropertiesTest {
public static void main(String[] args) throws Exception{
Properties properties = new Properties();
properties.load(PropertiesTest.class.getClassLoader().getResourceAsStream("application.properties"));
System.out.println(properties.getProperty("bean"));
}
}
application.properties文件:
bean= "application.properties"
输出:"application.properties"