接口地址

http://commons.apache.org/proper/commons-lang/javadocs/api-3.9/

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<!-- https://search.maven.org/artifact/org.apache.commons/commons-lang3/3.12.0/jar -->
<dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.12.0</version>
</dependency>

字符串

判断字符串 不为空和null

StringUtils.isNotEmpty(xxxx)

移除两边空字符串

StringUtils.trim(xxxx)

移除空格

StringUtils.deleteWhitespace(xxxx)

移除指定开头字符

StringUtils.removeStart("www.foxwho.com","www.foxwho")

删除指定字符串

StringUtils.strip(xxxx)

字符串对比

StringUtils.equals(null, null)

忽略大小写

StringUtils.equalsIgnoreCase(null, null)

字符位置

StringUtils.indexOf("XX", "X")

字符串包含

StringUtils.contains("XX", "X")

判断字符串是否以指定的字符序列数组中任意一个开头,区分大小写:

StringUtils.startsWithAny(null, null);// false
StringUtils.startsWithAny(null, new String[] { "abc" });// false
StringUtils.startsWithAny("abcxyz", null);// false
StringUtils.startsWithAny("abcxyz", new String[] { "" });// true
StringUtils.startsWithAny("abcxyz", new String[] { "abc" });// true
StringUtils.startsWithAny("abcxyz", new String[] { null, "xyz", "abc" });// true
StringUtils.startsWithAny("abcxyz", null, "xyz", "ABCX");// false
StringUtils.startsWithAny("ABCXYZ", null, "xyz", "abc");// false

字符串截取

StringUtils.substring("XX", "X")

字符串分割成数组

StringUtils.split("XX=X")

数组拆分成字符串

StringUtils.join(["XX", "X"])

字符串自动补齐

右补齐

StringUtils.rightPad("23",5,"0");

结果

23000

左补齐

StringUtils.leftPad("23",5,"0");

结果

00023

中部补齐

StringUtils.center(String str,int size,String padStr);

首字母大写

StringUtils.capitalize()

反向大写 StringUtils.swapCase

判断是否字母

StringUtils.isAlpha

字符串翻转

StringUtils.reverse

忽略字符串

StringUtils.abbreviate

字符串包装

StringUtils.wrap

数组

数组中是否包含字符串,数组中是否存在指定的元素

import org.apache.commons.lang3.ArrayUtils;String[] arr=new String[]{"aaa","bbbb","cccc"}
String value="cccc";
ArrayUtils.contains(arr,value);
不要使用 arrays.aslist(arr).contains(value)

数组过滤空或null,返回过滤后的

List<String> ids=new ArrayList<>();
ids.add("1");
ids.add("2");
ids.add("xx");
ids.add(null);
ids.add("");
List<String> data=ids.stream().filter(org.apache.commons.lang3.StringUtils::isNotBlank).collect(Collectors.toList());
System.out.println(data);
//或者
List<String> data2=ids.stream().filter(string -> !string.isEmpty()).collect(Collectors.toList());
System.out.println(data2);

部分来源:

https://blog.csdn.net/qq_39964694/article/details/80334556

java 开发时常用的工具类包 commons-lang3相关推荐

  1. [项目过程中所遇到的各种问题记录]工具篇——.NET开发时常用的工具类库

    在日常开发的过程当中我们总是会根据项目的开发需求将一些公用的类或者方法进行抽象封装,这些类或方法的抽象封装可能是基于某个项目或者多个项目,最常见的应该就是SQLHelper了,这些类库在实际使用的过程 ...

  2. JAVA 开发中常用的工具有哪些?

    Java开发中常用的工具有以下几种: Eclipse:一款非常流行的开发工具,提供了很多方便的功能,如代码自动补全.调试.版本控制等. IntelliJ IDEA:一款功能强大的Java集成开发环境, ...

  3. java web 项目 常用 小工具类 ~~~~

    java web 项目 常用 小工具类 ~~~~ 一 .DateUtil  日期工具类 package com.devframe.common.util;import java.text.Simple ...

  4. java 项目中常用的工具类总结

    1.文件 1.根据图片的链接,下载图片 package com.lingxu.module.BigDataJoinMessage.util;import java.io.FileOutputStrea ...

  5. java中时间常用处理工具类-DateUtils

    仅供参考,收录了一些常用的java中关于时间的处理方法,希望能帮到你! import org.apache.commons.lang3.time.DateFormatUtils;import java ...

  6. 连接数据库时常用的工具类(一)-------C3P0XmlUtils

    工具类一:C3P0XmlUtils 使用前应先把c3p0-config.xml 文件导入到Src的根目录下,如下图 下面为C3P0XmlUtils工具类: package cn.kgc.c3p0_xm ...

  7. java开发excel导入导出工具类基于EasyExcel

    一.工具类 import com.alibaba.excel.EasyExcel; import com.alibaba.excel.write.style.column.LongestMatchCo ...

  8. Java并发中常用同步工具类

    为什么80%的码农都做不了架构师?>>>    同步工具类可以是任何一个对象,只要它根据其自身的状态来协调线程控制流.阻塞队列(BlockingQueue)可以作为同步工具类,其他类 ...

  9. Android常用的工具类

    2019独角兽企业重金招聘Python工程师标准>>> 最新最准确内容建议直接访问原文:Android常用的工具类 主要介绍总结的Android开发中常用的工具类,大部分同样适用于J ...

  10. java中常用的工具类

    1. 常用零散工具类 1.1[DateUtil.java]日期处理的工具类 /*** 时间日期处理工具* String -> Date* Date -> String* 以及生成含有日期的 ...

最新文章

  1. Linux关机命令总结
  2. Jquery获取ckEditor的内容
  3. 使用JDK 13查看TLS配置
  4. 《Python Cookbook 3rd》笔记(3.1):数字的四舍五入
  5. 健康饮食-美味诱人的鸡肉香菇烩什锦[我写绿色IT]
  6. Dialog 基本使用
  7. conda创建和使用python的虚拟环境
  8. 利用泛型与反射更新实体(ADO.NET Entity Framework)
  9. 数组最大子数组和(续)之动态规划
  10. oa服务器日常维护,OA系统的日常维护工作有哪些
  11. endnote X7使用方法
  12. 宏想固态无法格式化,SM2258XT主控开卡成功经验,SM2259XT可参考
  13. 大气压随温度变化表_空气密度随温度的变化
  14. sql server order by 的一些高级用法
  15. 第四篇机器学习投资组合——模型测试
  16. JavaWeb——会话追踪之Cookie和Session
  17. 手游开发神器 cocos2d-x editor 教程聚合和代码下载(持续更新中)
  18. AT24C1024读写
  19. linux内核是如何实现分页机制的
  20. 邮储银行软件开发中心(实习) 面经

热门文章

  1. 当债务危机遇上限贷放松 房价投资价值大不如前
  2. AndroidManifest.xml 中application 的 android:name 属性作用
  3. 关于机器学习一些好的博客和资料
  4. mysql分组取每组前几条记录_[转] mysql分组取每组前几条记要(排名)
  5. python np数组中括号里面‘:n‘与‘n:‘什么意思
  6. C++中的->用于赋值
  7. UserWarning: h5py is running against HDF5 1.10.5 when it was built against 1.10.4
  8. 时间序列数据建模分析利器sktime初体验
  9. PCA计算点云的法线
  10. ie选项 由于该计算机受到限制 本次操作已被取消,IE“Internet 选项”无法打开提示“由于该计算机受到限制本次操作已被取消”...