commons-lang3
commons-lang3是apache提供的一个字符串处理工具,经过实践开发感觉这个工具非常不错
下载地址
改jar包需要在jdk1.6及以上运行
使用方法
因为是一个工具类,没有什么难用的,我就直接放上我自己写的一些测试类,仅供大家参考。
import org.apache.commons.lang3.StringUtils;
/**
* commons-lang3测试
* http://commons.apache.org/proper/commons-lang/download_lang.cgi
* @author hb-tmy
*
*/
public class test {
/**
*
*
* @param args
*/
public static void main(String[] args) {
// 截取特定区域内部字符串
String str = "{asdfghjk}";
String substringBetween = StringUtils.substringBetween(str, "{", "}");
System.out.println(substringBetween.toString()); // out asdfghjk
// 判断字符串是否为空
System.out.println(StringUtils.isEmpty("")); // out true
System.out.println(StringUtils.isNotEmpty("")); // out false
System.out.println(StringUtils.isEmpty(" ")); // out false
System.out.println(StringUtils.isNotEmpty(" ")); // out true
System.out.println(StringUtils.isBlank("")); // out true
System.out.println(StringUtils.isBlank(" ")); // out true
// 判断一个字符串是否为数值
System.out.println(StringUtils.isNumeric("2321312a")); // out false
System.out.println(StringUtils.isNumeric("2321312")); // out true
}
}
本文介绍了Apache提供的commons-lang3工具库,它包含了一系列强大的字符串处理功能。文章通过示例展示了如何使用该工具进行字符串截取、判断空值及是否为数值等操作。
771

被折叠的 条评论
为什么被折叠?



