- 浏览: 730991 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
z6978445:
查询呢?比如要查出 tblRead200710 表与 tblR ...
使用hibernate SQLQuery实现动态表 -
xtp1211:
乱发,自己都没试过
windows下的apache限制IP连接数 -
guanqing123:
在apache的httpd.conf文件中加入
ProxyRe ...
apache2.2 tomcat6 集群 -
wangxingchun:
Thanks again
Axure RP组件库下载 -
feiyu86:
这才是专家嘛,通俗易懂。
Lucene倒排索引原理
我们经常会对字符串进行操作,spring已经实现了常用的处理功能。我们可以使用org.springframework.util.StringUtils 工具类帮我们处理字符串。
工具类整理如下:
StringUtils.hasLength(null) = false
StringUtils.hasLength("") = false
StringUtils.hasLength(" ") = true
StringUtils.hasLength("Hello") = true
StringUtils.hasText(null) = false
StringUtils.hasText("") = false
StringUtils.hasText(" ") = false
StringUtils.hasText("12345") = true
StringUtils.hasText(" 12345 ") = true
//是否包含空白字符
StringUtils.containsWhitespace(null)=false
StringUtils.containsWhitespace("")=false
StringUtils.containsWhitespace("a")=false
StringUtils.containsWhitespace("abc")=false
StringUtils.containsWhitespace("abc")=false
StringUtils.containsWhitespace(" ")=true
StringUtils.containsWhitespace(" a")=true
StringUtils.containsWhitespace("abc ")=true
StringUtils.containsWhitespace("a b")=true
StringUtils.containsWhitespace("a b")
StringUtils.trimWhitespace(null)=null;
StringUtils.trimWhitespace("")="";
StringUtils.trimWhitespace(" ")="";
StringUtils.trimWhitespace("\t")="";
StringUtils.trimWhitespace(" a")="a";
StringUtils.trimWhitespace("a ")="a";
StringUtils.trimWhitespace(" a ")="a";
StringUtils.trimWhitespace(" a b ")="a b";
StringUtils.trimLeadingWhitespace(null)=null;
StringUtils.trimLeadingWhitespace("")="";
StringUtils.trimLeadingWhitespace(" ")="";
StringUtils.trimLeadingWhitespace("\t")="";
StringUtils.trimLeadingWhitespace(" a")="a";
StringUtils.trimLeadingWhitespace("a ")="a ";
StringUtils.trimLeadingWhitespace(" a ")="a ";
StringUtils.trimLeadingWhitespace(" a b ")="a b "
StringUtils.trimLeadingWhitespace(" a b c ")="a b c "
StringUtils.trimTrailingWhitespace(null)=null;
StringUtils.trimTrailingWhitespace(" ")="";
StringUtils.trimTrailingWhitespace("\t")="";
StringUtils.trimTrailingWhitespace("a ")="a";
StringUtils.trimTrailingWhitespace(" a")=" a";
StringUtils.trimTrailingWhitespace(" a ")=" a";
StringUtils.trimTrailingWhitespace(" a b ")=" a b";
StringUtils.trimTrailingWhitespace(" a b c ")=" a b c";
StringUtils.trimAllWhitespace("")="";
StringUtils.trimAllWhitespace(" ")="";
StringUtils.trimAllWhitespace("\t")="";
StringUtils.trimAllWhitespace(" a")="a";
StringUtils.trimAllWhitespace("a ")="a";
StringUtils.trimAllWhitespace(" a ")="a";
StringUtils.trimAllWhitespace(" a b ")="ab";
StringUtils.trimAllWhitespace(" a b c "="abc";
//统计一个子字符串在字符串出现的次数
StringUtils.countOccurrencesOf(null, null) == 0;
StringUtils.countOccurrencesOf("s", null) == 0;
StringUtils.countOccurrencesOf(null, "s") == 0;
StringUtils.countOccurrencesOf("erowoiueoiur", "WERWER") == 0;
StringUtils.countOccurrencesOf("erowoiueoiur", "x")=0;
StringUtils.countOccurrencesOf("erowoiueoiur", " ") == 0;
StringUtils.countOccurrencesOf("erowoiueoiur", "") == 0;
StringUtils.countOccurrencesOf("erowoiueoiur", "e") == 2;
StringUtils.countOccurrencesOf("erowoiueoiur", "oi") == 2;
StringUtils.countOccurrencesOf("erowoiueoiur", "oiu") == 2;
StringUtils.countOccurrencesOf("erowoiueoiur", "oiur") == 1;
StringUtils.countOccurrencesOf("erowoiueoiur", "r") == 2;
//字符串替换
String inString = "a6AazAaa77abaa";
String oldPattern = "aa";
String newPattern = "foo";
// Simple replace
String s = StringUtils.replace(inString, oldPattern, newPattern);
s.equals("a6AazAfoo77abfoo")=true;
// Non match: no change
s = StringUtils.replace(inString, "qwoeiruqopwieurpoqwieur", newPattern);
s.equals(inString)=true
s = StringUtils.replace(inString, oldPattern, null);
s.equals(inString)=true
// Null old pattern: should ignore
s = StringUtils.replace(inString, null, newPattern);
s.equals(inString)=true
//删除字符串
String inString = "The quick brown fox jumped over the lazy dog";
String noThe = StringUtils.delete(inString, "the");
noThe.equals("The quick brown fox jumped over lazy dog")=true;
String nohe = StringUtils.delete(inString, "he");
nohe.equals("T quick brown fox jumped over t lazy dog")=true;
String nosp = StringUtils.delete(inString, " ");
nosp.equals("Thequickbrownfoxjumpedoverthelazydog")=true;
String killEnd = StringUtils.delete(inString, "dog");
killEnd.equals("The quick brown fox jumped over the lazy ")=true;
String mismatch = StringUtils.delete(inString, "dxxcxcxog");
mismatch.equals(inString)=true;
//删除任何字符
//源代码如下
//char c = inString.charAt(i);
//如果不存在 c 值,则返回 -1
//if (charsToDelete.indexOf(c) == -1) {
//out.append(c);
//}
String inString = "Able was I ere I saw Elba";
String res = StringUtils.deleteAny(inString, "I");
res.equals("Able was ere saw Elba")=true;
res = StringUtils.deleteAny(inString, "AeEba!");
res.equals("l ws I r I sw l")=true;
String mismatch = StringUtils.deleteAny(inString, "#@$#$^");
mismatch.equals(inString)=true;
//源代码如下 return (str != null ? "'" + str + "'" : null);
assertEquals("'myString'", StringUtils.quote("myString"));
assertEquals("''", StringUtils.quote(""));
assertNull(StringUtils.quote(null));
//将第一个字符改大写
StringUtils.capitalize(Str)
//将第一个个字符改小写
StringUtils.uncapitalize(str)
//mypath/myfile.txt" -> "myfile.txt
//获取字符串文件名和扩展名
StringUtils.getFilename("myfile").equals("myfile")=true;
StringUtils.getFilename("mypath/myfile".equals("myfile")=true;
StringUtils.getFilename("mypath/myfile".equals("myfile")=true;
StringUtils.getFilename("myfile.txt").equals("myfile.txt")=true;
StringUtils.getFilename("mypath/myfile.txt").equals("myfile.txt")=true;
//获取字符串扩展名,以.分隔
StringUtils.getFilenameExtension("myfile")=null;
StringUtils.getFilenameExtension("myPath/myfile")=null;
StringUtils.getFilenameExtension("myfile.").equals("")=true;
StringUtils.getFilenameExtension("myPath/myfile.").equals("")=true;
StringUtils.StringUtils.getFilenameExtension("myfile.txt").equals("txt")=true;
StringUtils.getFilenameExtension("mypath/myfile.txt").equals("txt")=true;
//舍去文件名扩展名
StringUtils.stripFilenameExtension(null)=true;
StringUtils.stripFilenameExtension("").equals("")=true;
StringUtils.stripFilenameExtension("myfile").equals("myfile")=true;
StringUtils.stripFilenameExtension("mypath/myfile").equals("mypath/myfile")=true;
StringUtils.stripFilenameExtension("myfile.").equals("myfile")=true;
StringUtils.stripFilenameExtension("mypath/myfile.").equals("mypath/myfile")=true;
StringUtils.stripFilenameExtension("mypath/myfile.").equals("mypath/myfile")=true;
StringUtils.stripFilenameExtension("myfile.txt").equals("myfile")=true;
StringUtils.stripFilenameExtension("mypath/myfile.txt").equals("mypath/myfile")=true;
发表评论
-
Eclipse常用插件列表
2010-03-03 21:21 2305Properties Editor Pro ... -
slf4j简介
2010-02-23 12:00 3049SLF4J不是具体的日志解决方案,它只服务于各种各样的日志系 ... -
SSO单点登录解决方案
2009-10-20 11:18 19791 什么是单点登陆 单点登录(Single Sign ... -
减少全局竞争性同步,提高应用的垂直扩展能力
2009-10-20 10:44 1613减少全局竞争性同步, ... -
插入算法
2009-10-10 11:04 2018插入排序(Insertion Sort)的算法描述是一种简单直 ... -
鸡尾酒排序
2009-10-09 14:49 2119也就是定向冒泡排序, 鸡尾酒搅拌排序, 搅拌排序 (也可以视 ... -
冒泡排序法
2009-10-09 14:46 1607冒泡排序(BubbleSort)的基本概念是:依次比较相邻的两 ... -
JSTL <fmt:formatDate/>
2008-12-29 16:27 11971fmt:formatDate 的输出格式 <fmt:fo ... -
iBatis与Spring集成的批处理
2008-11-28 14:30 2523public String insertBatch(fina ... -
xfire 无法启动
2008-09-24 11:22 1595一般情况下,做ssh组合时,spring是通过web.xml加 ... -
C# 加密 java解密 (DES)
2008-08-13 21:26 5734C#中对数据进行加密,java对加密后的数据解密。 c# ... -
BigDecimal对象的用法(加减乘除)
2008-06-05 15:03 15888java.math.BigDecimal。BigDecimal ... -
利用过滤器对hibernate的session管理,实现session在线程范围内的共享
2008-03-12 18:13 4930hibernate中的Session关系到对数据库的增删查改等 ... -
log4j.properties 使用
2008-03-06 13:12 1565一.参数意义说明输出级别的种类ERROR、WARN、INFO、 ... -
spring2 整合 Dwr(把DWR的配置写到Spring的配置文件)
2008-03-03 16:22 3413Spring 2基于XML Schema的配置,Spring ... -
maven 配置篇之pom.xml
2008-02-29 16:01 1658什么是pom? pom作为项目对象模型。通过xml表示m ... -
maven 配置篇之settings.xml
2008-02-29 15:58 2259maven2 比起maven1 来说,需要配置的文件少多了,主 ... -
maven体验(1)
2008-02-29 11:28 15441.下载maven 地址:http://www.apac ... -
Maven中几个重要的概念
2008-02-29 11:23 2331在Maven中有几个重要的概念需要了解: 一、project ... -
spring rmi应用
2008-02-17 11:26 6664利用Spring来实现RMI,不用实现remote接口,也不用 ...
相关推荐
org.springframework.web.util.HtmlCharacterEntityReferences.class org.springframework.web.util.HtmlUtils.class org.springframework.web.util.HttpSessionMutexListener.class org.springframework.web.util....
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
Spring框架依赖jar包,其中最小依赖包:org.springframework.core、org.springframework.context、org.springframework.beans、org.springframework.asm、org.springframework.expression、...
org.apache.commons.net.util.jar
axis2解决 org.apache.axis2.util.JavaUtils.callStackToString问题
spring 4.0 未翻译java.lang....org.springframework.core.OrderComparator (implements java.util.Comparator) org.springframework.core.annotation.AnnotationAwareOrderComparator Annotation Type Hierarchy
<groupId>org.springframework.boot <artifactId>spring-boot-starter-parent <version>2.1.4.RELEASE <relativePath/> <!-- lookup parent from repository --> <groupId>com.example</groupId> ...
import org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet; import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; ...
org.apache.poi JAR包,解决个人的 import org.apache.commons.beanutils.PropertyUtilsBean;...import org.apache.poi.ss.util.CellRangeAddress; "The import org.apache.poi cannot be resolved"的问题
<Call Stack = DEBUG_FRAME = org.apache.axis2.util.JavaUtils.callStackToString(JavaUtils.java:564) DEBUG_FRAME = org.apache.axis2.description.ParameterIncludeImpl.debugParameterAdd(ParameterIncludeImpl...
下载HttpClient,解压,在Eclipse中导入所有JAR import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache....import org.apache.http.util.EntityUtils;
予org.jasig.cas.client.util.CommonUtils 加入 public static void disableSSLVerification(){ try { // Create a trust manager that does not validate certificate chains TrustManager[] ...
spring-framework-3.0.5.RELEASE-dependencies 好不容易找到了,赶紧分享一下 因为不能大于20M,共分了8个包,都是...org.springframework.build org.testng org.xmlpull org.joda org.jruby org.junit org.objectweb.asm
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.Region; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.util.CellRangeAddress; "The import ...
org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar
spring2.5基于注解的例子程序,包含相关jar包
最全的一份spring的jar包,让你在学习spring的时候不用花时间再去找包
spring-framework-3.0.5.RELEASE-dependencies 好不容易找到了,赶紧分享一下 因为不能大于20M,共分了8个包,都是...org.springframework.build org.testng org.xmlpull org.joda org.jruby org.junit org.objectweb.asm
spring-framework-3.0.5.RELEASE-dependencies 好不容易找到了,赶紧分享一下 因为不能大于20M,共分了8个包,都是...org.springframework.build org.testng org.xmlpull org.joda org.jruby org.junit org.objectweb.asm
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping;...