zoukankan      html  css  js  c++  java
  • Common lang一些边界方法总结(好记性不如烂笔头,需要慢慢积累).一定要利用好现有的轮子,例如Apache common与Google Guava

    好记性真是不如烂笔头啊!!!!

    如下代码:

      List<String> list = new ArrayList<String>();
            list.add("1");
            list.add("2");
            list.add("3");
            System.out.println(list.toString());
            System.out.println(StringUtils.strip(list.toString(),"[]"));
            System.out.println(StringUtils.strip("ab122122abc121bca","abc"));

    输出:

    [1, 2, 3]
    1, 2, 3
    122122abc121

      

    通过输出就可以看出只要str的开始与结束的字符是stripChars中的话则就删除。

    apache common collections :

    <!-- https://mvnrepository.com/artifact/commons-collections/commons-collections -->
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.1</version>
    </dependency>
    

      

    最近写代码使用到反射,是自己使用jdk基础类库实现,虽然自己实现的代码相对也比较简装没有什么bug,但是代码量和代码优雅程序还是不如直接使用现有类库来的简单粗暴。当然也不能把类库当做黑盒使用,有时间还是要做看看源码了解一下实现思路。在代码编写时想到了之前用过的工具类:

    <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.3</version>
    </dependency>
    

      多积累多实用 多看源码

  • 相关阅读:
    给Apache增加SSI支持(shtml的奥秘)
    Raphael实现商品来源去向图
    有趣的居中方式
    oc-基本语法
    APMServ 配置记录
    解决Mac Chrome打开HTTPS证书错误问题
    JavaScript生成GUID的算法
    Backbone模型
    利用apply和arguments复用方法
    软件复用的几种方式
  • 原文地址:https://www.cnblogs.com/leodaxin/p/9082973.html
Copyright © 2011-2022 走看看