package com.ynet.utils; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Created by Arya on 2017/11/3 0003. */ public class StringUtil { //去除所有空格 public static String replaceAllBlank(String str) { String s = ""; if (str!=nul
代码: String str = "the music made it hard to concentrate"; String delims = "[ ]+"; String[] tokens = str.split(delims); 结果为: the, music, made, it, hard, to, concentrate 原因: String.split(String regex):参数是一个正则表达式 转自:http://pages.cs.wisc.e
java中String的常用方法 1.length() 字符串的长度 例:char chars[]={'a','b'.'c'}; String s=new String(chars); i nt len=s.length(); 2.charAt() 截取一个字符 例:char ch; ch="abc".charAt(1); 返回'b' 3. getChars() 截取多个字符 例:String s="this is a demo of the getChars method.
我们知道在mybatis的映射中传参数,只能传入一个.通过#{参数名} 即可获取传入的值. Mapper接口文件: public int delete(int id) throws Exception; MapperL配置文件: <delete id="delete" parameterType="int"> delete from user where id=#{id} </delete> 接口中我们定义了delete(int id),形参
我们知道在mybatis的映射中传参数,只能传入一个.通过#{参数名} 即可获取传入的值. Mapper接口文件: public int delete(int id) throws Exception;1MapperL配置文件: <delete id="delete" parameterType="int"> delete from user where id=#{id}</delete>123接口中我们定义了delete(int id),形
由于我们处理的日志需要过滤一些空格,因此大部分处理日志的程序中都用到了java.lang.String.trim()函数.直到有一次遇到一个诡异的问题,某个包含特殊字符的字符串被trim后居然也为空(虽然这种特殊字符也没有什么太大意义-). 于是查看这个特殊字段,显示为^I(在Linux下可以通过cat -A命令能够查看这个特殊字符),对应键盘上的Tab键,于是便将trim()函数拉出来看了一下: public String trim() { int len = value.leng