Android开发好用的字符串处理工具

来源:互联网 发布:淘宝代收货款会计分录 编辑:程序博客网 时间:2024/06/13 03:56

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    }}
0 0
原创粉丝点击