StringUtils和CollectionUtils开发中应用

Java使用CollectionUtils集合工具类 CollectionUtils 是 Apache Commons Collections 库提供的集合操作工具类,主要用于简化 List、Set 等集合的常见操作。与 JDK 自带的 Collections 工具类不同,它提供了更多增强功能且能更好地处理 null 值。 阅读详情

StringUtils

1.引入依赖

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.8.1</version>
        </dependency>

2.常用方法(主要用在if()判断中的常用方法)

//引入的包
import org.apache.commons.lang3.StringUtils;
  • public static boolean isEmpty(String str)
    判断某字符串是否为空,为空的标准是 str==null 或 str.length()==0
StringUtils.isEmpty(null) = true
StringUtils.isEmpty("") = true 
StringUtils.isEmpty(" ") = false //注意在 StringUtils 中空格作非空处理
StringUtils.isEmpty("   ") = false
StringUtils.isEmpty("bob") = false
StringUtils.isEmpty(" bob ") = false
  • public static boolean isNotEmpty(String str)
    判断某字符串是否非空,等于 !isEmpty(String str)
StringUtils.isNotEmpty(null) = false
StringUtils.isNotEmpty("") = false
StringUtils.isNotEmpty(" ") = true
StringUtils.isNotEmpty("         ") = true
StringUtils.isNotEmpty("bob") = true
StringUtils.isNotEmpty(" bob ") = true
  • public static boolean isBlank(String str)
    判断某字符串是否为空或长度为0或由空白符(whitespace)或空格 构成
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUtils.isBlank(" ") = true
StringUtils.isBlank("        ") = true
StringUtils.isBlank("\t \n \f \r") = true   //对于制表符、换行符、换页符和回车符
 
StringUtils.isBlank()   //均识为空白符
StringUtils.isBlank("\b") = false   //"\b"为单词边界符
StringUtils.isBlank("bob") = false
StringUtils.isBlank(" bob ") = false
  • public static boolean isNotBlank(String str)
    判断某字符串是否不为空且长度不为0且不由空白符(whitespace) 构成,等于 !isBlank(String str)
StringUtils.isNotBlank(null) = false
StringUtils.isNotBlank("") = false
StringUtils.isNotBlank(" ") = false
StringUtils.isNotBlank("         ") = false
StringUtils.isNotBlank("\t \n \f \r") = false
StringUtils.isNotBlank("\b") = true
StringUtils.isNotBlank("bob") = true
StringUtils.isNotBlank(" bob ") = true

CollectionUtils

//引入的包
import org.apache.commons.collections.CollectionUtils;

1 引入依赖

       <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.2</version>
        </dependency>

2 常用方法

  • 判断集合是否为空
  CollectionUtils.isEmpty(null): true
 CollectionUtils.isEmpty(new ArrayList()): true  
 CollectionUtils.isEmpty({a,b}): false
  • 判断集合是否不为空
    CollectionUtils.isNotEmpty(null): false
    CollectionUtils.isNotEmpty(new ArrayList()): false
    CollectionUtils.isNotEmpty({a,b}): true
  • 并集
public void testUnion(){
    String[] arrayA = new String[] { "A", "B", "C", "D", "E", "F" };  
    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
    List<String> listA = Arrays.asList(arrayA);
    List<String> listB = Arrays.asList(arrayB);
    //2个数组取并集 
    System.out.println(ArrayUtils.toString(CollectionUtils.union(listA, listB)));
    //[A, B, C, D, E, F, G, H, K]
}
  • 交集
    String[] arrayA = new String[] { "A", "B", "C", "D", "E", "F" };  
    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
    List<String> listA = Arrays.asList(arrayA);
    List<String> listB = Arrays.asList(arrayB);
    //2个数组取交集 
    System.out.println(ArrayUtils.toString(CollectionUtils.intersection(listA, listB)));
    //[B, D, F]
  • 交集的补集(析取)
public void testDisjunction(){
    String[] arrayA = new String[] { "A", "B", "C", "D", "E", "F" };  
    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
    List<String> listA = Arrays.asList(arrayA);
    List<String> listB = Arrays.asList(arrayB);
    //2个数组取交集 的补集
    System.out.println(ArrayUtils.toString(CollectionUtils.disjunction(listA, listB)));
    //[A, C, E, G, H, K]
}
  • 差集(扣除)
public void testSubtract(){
    String[] arrayA = new String[] { "A", "B", "C", "D", "E", "F" };  
    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
    List<String> listA = Arrays.asList(arrayA);
    List<String> listB = Arrays.asList(arrayB);
    //arrayA扣除arrayB
    System.out.println(ArrayUtils.toString(CollectionUtils.subtract(listA, listB)));
    //[A, C, E]
 
}
  • 集合是否相等
    class Person{}
    class Girl extends Person{
    }
 
    List<Integer> first = new ArrayList<>();
    List<Integer> second = new ArrayList<>();
    first.add(1);
    first.add(2);
    second.add(2);
    second.add(1);
    Girl goldGirl = new Girl();
    List<Person> boy1 = new ArrayList<>();
    //每个男孩心里都装着一个女孩
    boy1.add(new Girl());
    List<Person> boy2 = new ArrayList<>();
    //每个男孩心里都装着一个女孩
    boy2.add(new Girl());
    //比较两集合值
    System.out.println(CollectionUtils.isEqualCollection(first,second));   //true
    System.out.println(CollectionUtils.isEqualCollection(first,boy1));   //false
    System.out.println(CollectionUtils.isEqualCollection(boy1,boy2));   //false
  • 不可修改的集合
  • 应用场景:c相当于数据库中传来的数据,然后通过 CollectionUtils.unmodifiableCollection()存入s中,现在的c和s值相同,但是s不可以修改,修改就会报错
public void testUnmodifiableCollection(){
    Collection<String> c = new ArrayList<>();
    Collection<String> s = CollectionUtils.unmodifiableCollection(c);
    c.add("boy");
    c.add("love");
    c.add("girl");
    //! s.add("have a error");  //修改后报错java.lang.UnsupportedOperationException
    System.out.println(s);
}
Java通用工具库common-utils-5.4.1完整解析与实战应用 是一款在Java企业级开发中广泛使用的轻量级工具库,封装了字符串处理、日期操作、集合运算、IO流管理等高频功能模块。该版本基于JDK 8+设计,兼容至JDK 17,通过强化异常安全机制与API一致性,显著提升了代码可维护性与运行稳定性。其核心采用静态工具类模式,支持零依赖引入,适用于微服务、批处理及高并发场景。-- Maven引入方式 -->源码结构清晰划分DateUtils等包模块,便于按需使用。本版本重点优化了的Unicode空白字符识别逻辑,并修复早期版本中。 阅读详情

相关推荐

【v4l2】在Android SDK中交叉编译v4l2-ctl

为调试Android设备中camera的相关功能,需要引入v4l2-ctl工具。由于厂商提供的Android SDK源码中未集成v4l2-utils(包含v4l2-ctl以及其它组件的工具包),故需要下载v4l2-utils源码,并在Android SDK中交叉编译生成v4l2-ctl可执行文件。本文讲述其过程步骤。

rentong123的博客 1322

CollectionUtils工具类的常用方法

集合判断:  例1: 判断集合是否为空:  CollectionUtils.isEmpty(null): true  CollectionUtils.isEmpty(new ArrayList()): true    CollectionUtils.isEmpty({a,b}): false  例2: 判断集合是否不为空:  CollectionU...

weixin_34067049的博客 329

SAP PI实战:5分钟搞定REST适配器同步接口配置(含Postman测试技巧)

本文详细介绍了如何在SAP PI中快速配置REST适配器同步接口,包括ESR设计、集成流配置及Postman测试技巧。通过实战步骤和关键参数设置,帮助开发者高效实现系统集成,特别适合需要实时数据交互的业务场景。

weixin_33738555的博客 485

Java必会的工具库

1. Java自带工具方法 1.1 List集合拼接成以逗号分隔的字符串 // 如何把list集合拼接成以逗号分隔的字符串 a,b,c List<String> list = Arrays.asList("a", "b", "c"); // 第一种方法,可以用stream流 String join = list.stream().collect(Collectors.joining(",")); System.out.println(join); // 输出 a,b,c

OutRoading的博客 464

STM32 Boot程序实战:从启动流程到安全跳转机制解析

本文深入解析STM32 Boot程序的核心作用与安全跳转机制,涵盖启动流程、内存管理、中断向量表重定向及固件验证等关键环节。通过实战案例分享如何实现可靠的固件升级与故障回退策略,避免设备变砖风险,提升嵌入式系统稳定性。

pluto的博客 779

6.2 磁悬浮轴承:软件架构与实现

本文系统阐述了磁悬浮轴承控制系统的软件架构与实现方法。采用分层架构设计,包括硬件抽象层、实时控制内核、控制算法层和应用层,确保系统实时性和可靠性。重点分析了电流环、位置环等关键控制任务的调度策略,比较了不同硬件平台(DSP、ARM、FPGA)的软件实现方案。强调模块化设计、配置化管理等工程实践,并详细介绍了从算法仿真到系统联调的完整开发流程。最后指出严格的测试验证是保证系统性能的关键,需通过多阶段测试评估起浮时间、稳态精度等核心指标。

技术工作者 752

apache commons collections CollectionUtils工具类简单使用

一. CollectionUtils提供很多对集合的操作方法,常用的方法如下: 集合判断: 例1: 判断集合是否为空: CollectionUtils.isEmpty(null): true CollectionUtils.isEmpty(new ArrayList()): true CollectionUtils.isEmpty({a,b}): false 例2: 判断集合是否不为空: CollectionUtils.isNotEmpty(null): false CollectionUtils.i

dgzhang_reg的博客 4734

2026华为OD机考双机位C卷++ 双机位B卷 + 双机位A卷 + 2025C/B/A卷+ 往年真题 - 题库目录分值说明 + 考点说明+在线OJ

2025华为OD机考双机位C卷++ 双机位B卷 + 双机位A卷 + 2025C/B/A卷+ 往年真题 - 题库目录分值说明 + 考点说明+在线OJ

算法大师! 5万+

开发常用的工具类(ObjectUtils、StringUtils、CollectionUtils 和 BeanUtils)的使用

检查对象是否为空或 null。

m0_62506538的博客 1940

从基础到前沿:深度剖析光束整形与扫描技术

光束扫描的核心在于通过特定手段改变光束的传播方向,从而实现对目标区域的扫描。在这个过程中,振镜、声光偏转器、电光偏转器等元件发挥着关键作用。振镜是一种常见的光束扫描元件,它主要由电机、反射镜和透镜组成。当电机驱动反射镜旋转时,根据光的反射定律,反射镜会改变入射光线的反射方向。假设初始时光束垂直入射到反射镜上,当反射镜绕某一轴旋转一定角度时,光束的反射方向就会相应改变,从而实现光束在空间中的扫描。在激光打标设备中,通过控制振镜的快速摆动,能够使激光束在工件表面快速移动,完成各种图案和文字的标记。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 2098

解锁 Bootloader 不再难!HyperOS澎湃系统小米与红米手机通用

必要时,可以在工具右上角安装驱动模块,手动安装驱动。解决方法:确保手机升级到最新稳定版,登录同一个小米账号,并在。新机型解锁时需要等待一段时间,通常为 7 天。如果账号安全评分较低,解锁等待时间会更长。如果解锁失败提示权限不足,说明账号存在安全问题。出现这个错误时,通常是因为网络不稳定。如果解锁次数已满,需要等到下个月。解锁后,手机会重启,首次开机会稍微慢一些,等耐心等待即可。按钮,开始解锁过程,注意:解锁会清除手机内所有数据。7次,开启开发者选项。,右键解压到指定文件夹。,使用小米账号登录。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 7218

StringUtils 系列之 StringUtils.isBlank() 和 StringUtils.isNotBlank() 的区别、CollectionUtils.isEmpty()

【代码】StringUtils 系列之 StringUtils.isBlank() 和 StringUtils.isNotBlank() 的区别。

long_steve的博客 1174

[RK-Linux] 移植Linux-5.10到RK3399(十)| 配置AP6256模组使能WIFI、BT功能

[RK-Linux] 移植Linux-5.10到RK3399(十)| 配置AP6256模组使能WIFI、BT功能

Systemcall名屋 2978

StringUtils/Objects/CollectionUtils/(HtmlUtils前后端json传输) /(随机生成姓名、地址、电话等)工具类的常用方法

StringUtils 方法的操作对象是 Java.lang.String 类型的对象,是 JDK 提供的 String 类型操作方法的补充,并且是 null 安全的(即如果输入参数 String 为 null 则不会抛出 NullPointerException ,而是做了相应处理,例如,如果输入为 null 则返回也是 null 等,具体可以查看源代码) ——————————————...

qq_23095607的博客 640

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Java四大工具类实战指南:StringUtils与BeanUtils等高效应用

在Java开发中,工具类作为基础代码复用单元,通过封装常用操作显著提升开发效率。以Apache Commons和Spring框架为代表的工具类库,基于设计模式与算法优化,解决了字符串处理、对象拷贝等高频场景的健壮性问题。StringUtils通过空值安全校验和批量处理方法,使字符串操作性能提升17%以上;BeanUtils则利用反射机制实现属性拷贝,但需注意Spring与Apache版本的参数顺序差异。这些工具类在微服务参数校验、DTO转换等场景具有不可替代的价值,配合CollectionUtils的集合安

weixin_29288313的博客 223

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

科普文:Spring中18个常用工具类梳理

很多时候,我们需要在代码中做判断:如果不满足条件,则抛异常。有没有统一的封装呢?其实Spring给我们提供了Assert类,它表示断言。

为无为,事无事,味无味。 1387

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

分享17个提升开发效率的工具“轮子”

本文是向大家介绍平时在开发中经常用到的小工具,它能够极大得提升我们的开发效率,能够解决平时开发中遇到的问题。

weixin_43805705的博客 569

SpringBoot 内置工具类,太好用了

【代码】SpringBoot 内置工具类,太好用了。

li826827的博客 286

Spring框架本身自带的一些好用的工具类

有时候,我们需要在项目中使用反射功能,如果使用最原始的方法来开发,代码量会非常多,而且很麻烦,它需要处理一大堆异常以及访问权限等问题。很多时候,我们会在代码中定义http的返回码,比如:接口正常返回200,异常返回500,接口找不到返回404,接口不可用返回502等。在我们日常开发过程中,对字符串的操作是非常频繁的,但JDK提供的对于字符串操作的方法,过于简单,无法满足我们开发中的需求。对于后端的很多接口,经常需要去掉前后空格,我们可以使用String类的trim(),但是如果要同时去掉中间的空格呢?

qq_33141369的博客 1807

AtomicInteger原子类、判空工具类、比较时间大小

AtomicInteger原子类、判空工具类、比较时间大小

qq453660983的博客 2766

求你别自己瞎写工具类了,Spring自带的这些他不香吗?

断言 断言是一个逻辑判断,用于检查不应该发生的情况 Assert 关键字在 JDK1.4 中引入,可通过 JVM 参数-enableassertions开启 SpringBoot 中提供了 Assert 断言工具类,通常用于数据合法性检查 // 要求参数 object 必须为非空(Not Null),否则抛出异常,不予放行 // 参数 message 参数用于定制异常信息。 void notNull(Object object, String message) // 要求参数必须空(Null

加油,努力,认真 149

Apache Commons常用工具类

文章目录 Commons类库 StringUtils 两个字符串的比较 判断字符串是否为空 判断包含关系 DateUtils 日期增加 日期比较 其他 CollectionUtils FileUtils 拷贝文件或目录 删除文件或目录 读写文件 IOUtils HttpClient GetMethod PostMethod HttpURLConnection 加密 Base64 D

万事俱备,就差一个程序员了 837

常用判空

1.blank:代表的是空串("")、空白符(空格""," “,制表符”\t",回车符"\r","\n"等)以及null值; 2.empty:代表的是空串("")和null值,不包含空白符; 3.whitespace:包含空串("")和空白符,不包含null值. StringUtils.isBlank StringUtils.isAnyBlank和isAnyEmpty是多维判空,存在一个blank或者empty既true CollectionUtils.isEmpty 判断集合 ...

MasterYi的博客 364

Springboot中优雅进行字段校验

往期热门文章:1、Redis 实现限流的三种方式 2、推荐 15 款常用开发工具 3、一次 QPS 翻倍的 Java 服务性能优化 4、Maven 划分模块最佳实践 5、面试官问:sele...

Java之间 353

Java各种工具箱的使用

StringUtils 方法的操作对象是 Java.lang.String 类型的对象,是 JDK 提供的 String 类型操作方法的补充,并且是 null 安全的(即如果输入参数 String 为 null 则不会抛出 NullPointerException ,而是做了相应处理,例如,如果输入为 null 则返回也是 null 等。判断某字符串是否非空,等于!isBlank(String str)(2)if(s == null || s.length()

weixin_44823875的博客 1781

求你别自己瞎写工具类了,Spring自带的这些他不香麽?

相关阅读:2T架构师学习资料干货分享最近发现同事写了不少重复的工具类,发现其中很多功能,Spring 自带的都有。于是整理了本文,希望能够帮助到大家!断言断言是一个逻辑判断,用于检查不应...

Java和Android架构 81
上一篇: SpringBoot集成TkMybatis
下一篇: SpringBoot中的单元测试
jothan_lee
博客等级 码龄9年 30粉丝 58原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值