# 文件读取 - FileRader
 | public static void main(String[] args)  | 
 | { | 
 |    File src = new File("E:\\test.txt"); | 
 |    FileReader fr = null;  | 
 |    InputStream input = null;  | 
 |    try  | 
 |    { | 
 |         | 
 |       fr = new FileReader(src);  | 
 |       input = FileUtil.getInputStream(src);  | 
 |       ArrayList<String> readLines = IoUtil.readLines(fr, new ArrayList<>());  | 
 |         | 
 |       ArrayList<String> readUtf8Lines = IoUtil.readUtf8Lines(input, new ArrayList<>());  | 
 |         | 
 |       ArrayList<String> readLines1 = IoUtil.readLines(input, "UTF-8", new ArrayList<>());  | 
 |       for (String readLine : readLines)  | 
 |       { | 
 |          System.out.println(readLine);  | 
 |       }  | 
 |    } catch (FileNotFoundException e)  | 
 |    { | 
 |       throw new RuntimeException(e);  | 
 |    } finally  | 
 |    { | 
 |       try  | 
 |       { | 
 |            | 
 |          if (fr != null)  | 
 |          { | 
 |             fr.close();  | 
 |          }  | 
 |          if (input != null)  | 
 |          { | 
 |             input.close();  | 
 |          }  | 
 |       } catch (IOException e)  | 
 |       { | 
 |          throw new RuntimeException(e);  | 
 |       }  | 
 |    }  | 
 | }  | 
# 判断 null
 | public static void main(String[] args)  | 
 | { | 
 |      | 
 |    List<String> a = null;  | 
 |    System.out.println("定义一个集合null:" + ObjectUtil.isEmpty(a) + "----" + ObjectUtil.isNull(a)); | 
 |      | 
 |    ArrayList<String> b = new ArrayList<>();  | 
 |    System.out.println("定义一个集合为空:" + ObjectUtil.isEmpty(b) + "----" + ObjectUtil.isNull(b)); | 
 | }  | 
定义一个集合null:true----true
定义一个集合为空:true----false
# 检测 Html 标签
 | public static void main(String[] args)  | 
 | { | 
 |      | 
 |    String escape = HtmlUtil.escape("<div>这是一段html</div>"); | 
 |      | 
 |    System.out.println(escape);  | 
 |      | 
 |    System.out.println(HtmlUtil.unescape(escape));  | 
 |      | 
 |    System.out.println(ReUtil.contains(HtmlUtil.RE_HTML_MARK, "<div>这是一段html</div>"));  | 
 | }  | 
打印结果:
<div>这是一段html</div>
<div>这是一段html</div>
true
# 字符串处理
 | public static void main(String[] args)  | 
 | { | 
 |    String str = "test";  | 
 |      | 
 |    System.out.println(StrUtil.isEmpty(str));  | 
 |    System.out.println(StrUtil.isNotEmpty(str));  | 
 |      | 
 |    System.out.println(StrUtil.removeSuffix("a.jpg", ".jpg")); | 
 |    System.out.println(StrUtil.removePrefix("a.jpg", "a.")); | 
 |      | 
 |    String template = "这只是个占位符:{}"; | 
 |    String str1 = StrUtil.format(template, "我是占位符");  | 
 |    System.out.println("strUtil format:" + str1); | 
 | }  | 
打印结果:
false
true
a
jpg
strUtil format:这只是个占位符:我是占位符
# Validator
 | public static void main(String[] args)  | 
 | { | 
 |      | 
 |    System.out.println(Validator.isUrl("http://www.baidu.com")); | 
 |      | 
 |    System.out.println(Validator.isEmail("test@qq.com")); | 
 |      | 
 |    System.out.println(Validator.isLowerCase("Abc")); | 
 | }  | 
打印结果:
true
true
false
# 转换
 | public static void main(String[] args)  | 
 | { | 
 |    int a = 1;  | 
 |      | 
 |    String aStr = Convert.toStr(a);  | 
 |    System.out.println(aStr);  | 
 |    String b[] = {"1", "2", "3"}; | 
 |      | 
 |    Integer[] bArr = Convert.toIntArray(b);  | 
 |    System.out.println(bArr);  | 
 |    String dateStr = "2017-05-06";  | 
 |      | 
 |    Date date = Convert.toDate(dateStr);  | 
 |    System.out.println(date);  | 
 |    String strArr[] = {"A", "B", "C"}; | 
 |      | 
 |    List<String> list = Convert.toList(String.class, strArr);  | 
 |    System.out.println(list);  | 
 | }  | 
打印结果:
1
[Ljava.lang.Integer;@2077d4de
Sat May 06 00:00:00 CST 2017
[A, B, C]
# 创建新集合
 | public static void main(String[] args)  | 
 | { | 
 |    String[] array = {"a", "b", "c", "d", "e"}; | 
 |      | 
 |    ArrayList<String> list = CollUtil.newArrayList(array);  | 
 |      | 
 |    String join = CollUtil.join(list, ",");  | 
 |    System.out.println(join);  | 
 |      | 
 |    List<String> split = StrUtil.split(join, ",");  | 
 |    System.out.println(split);  | 
 |      | 
 |    HashSet<Object> newHashSet = CollUtil.newHashSet();  | 
 |    ArrayList<Object> newList = CollUtil.newArrayList();  | 
 |      | 
 |    HashMap<Object, Object> newMap = MapUtil.newHashMap();  | 
 |      | 
 |    MapUtil.isEmpty(newMap);  | 
 |      | 
 |    MapUtil.isNotEmpty(newMap);  | 
 | }  | 
# 创建新的数组
 | public static void main(String[] args)  | 
 | { | 
 |    String newArray[] = ArrayUtil.newArray(String.class, 3);  | 
 |    String sta[] = {"1", "2"}; | 
 |    ArrayUtil.isNotEmpty(sta);  | 
 | }  | 
# Bean 转换
 | public static void main(String[] args)  | 
 | { | 
 |    Test10 d = new Test10();  | 
 |    d.setId(1);  | 
 |    d.setName("刘桑"); | 
 |      | 
 |    Map<String, Object> map = BeanUtil.beanToMap(d);  | 
 |    System.out.println("beanUtil bean to Map:" + map); | 
 |      | 
 |    Test10 d1 = BeanUtil.mapToBean(map, Test10.class, false);  | 
 |    System.out.println("beanUtil Map to bean:" + d1); | 
 |      | 
 |    Test10 d2 = new Test10();  | 
 |      | 
 |    BeanUtil.copyProperties(d, d2);  | 
 |    System.out.println("beanUtil copy properties:" + d2); | 
 | }  | 
打印结果:
beanUtil bean to Map:{id=1, name=刘桑}
beanUtil Map to bean:Test10{id=1, name='刘桑'}
beanUtil copy properties:Test10{id=1, name='刘桑'}
# 判断是否为内网
 | public static void main(String[] args)  | 
 | { | 
 |      | 
 |    System.out.println(NetUtil.isInnerIP("192.168.3.35")); | 
 | }  |