知乎專欄 | 多維度架構 | | | 微信號 netkiller-ebook | | | QQ群:128659835 請註明“讀者” |
目錄
package cn.netkiller.apache.lang; import org.apache.commons.lang3.StringEscapeUtils; @SuppressWarnings("deprecation") public class LangTest { public static void main(String[] args) { // TODO Auto-generated method stub String html = "<span>Neo's book</span>"; String encode = StringEscapeUtils.escapeHtml4(html); String decode = StringEscapeUtils.unescapeHtml4(encode); System.out.println(encode); System.out.println(decode); } }
下面例子使用逗號連結字元串
org.apache.commons.lang.StringUtils.join(arraylist, ',')
String project = RandomStringUtils.randomAlphanumeric(10); System.out.print(project);
隨機輸出 ASCII
System.out.println(RandomStringUtils.randomAscii(10));
隨機輸出數字
System.out.println(RandomStringUtils.randomNumeric(10));
指定字元串隨機輸出
String project = RandomStringUtils.random(10, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").toString(); System.out.println(project);