com.aiyc.framework.utils
类 StringUtils

java.lang.Object
  继承者 com.aiyc.framework.utils.StringUtils

public class StringUtils
extends Object

常用字符串操作函数


构造方法摘要
StringUtils()
           
 
方法摘要
static int compareString(String s, String s1, String s2)
           
static String decodeString(String str)
          Decode a string using Base64 encoding.
static String defaultString(String ab)
           
static String encodePassword(String password, String algorithm)
          Encode a string using algorithm specified in web.xml and return the resulting encrypted password.
static String encodeString(String str)
          Encode a string using Base64 encoding.
static String formatChineseString(String s)
           
static int getStrIndex(String s, String[] args)
          从数组中得到字符串的位置
static boolean isEmpty(String ext)
           
static boolean isNullOrBank(String ext)
           
static String join(Iterator iterator, String s)
           
static String join(Object[] aobj, String s)
           
static String lowerFirstChar(String s)
          将首字母小写
static String merge(String[] src, String delimiter)
          合并字符串数组为一个串
static String nullToEmpty(String src)
          判断 如果输入的字符为null或者'null',输出空字符串""
static boolean objectEquals(Object obj, Object obj1)
           
static String replace(String line, String oldString, String newString)
          用 newString 替换 line 中的所有的 OldString。
static String replace(String line, String oldString, String newString, int[] count)
          用 newString 替换 line 中的所有的 OldString count返回被替换的数目
static String replaceIgnoreCase(String line, String oldString, String newString)
          做不区分大小写的模式匹配,并用newString 来替换 oldString
static String[] split(String ext)
           
static String[] split(String ext, char pix)
           
static String[] split(String str, int sect, int len)
          分解字符串
static boolean strEquals(String s, String s1)
           
static String toCamelCasing(String s)
          将下划线连接的String替换为驼峰风格
static String trimToByteSize(String s, String s1, int i)
           
static String upperFirstChar(String s)
          将首字母大写
static String URLEncode(String srcStr, String encoding)
          对整个url进行编码转换
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

StringUtils

public StringUtils()
方法详细信息

compareString

public static int compareString(String s,
                                String s1,
                                String s2)

encodePassword

public static String encodePassword(String password,
                                    String algorithm)
Encode a string using algorithm specified in web.xml and return the resulting encrypted password. If exception, the plain credentials string is returned

参数:
password - Password or other credentials to use in authenticating this username
algorithm - Algorithm used to do the digest
返回:
encypted password based on the algorithm.

encodeString

public static String encodeString(String str)
Encode a string using Base64 encoding. Used when storing passwords as cookies. This is weak encoding in that anyone can use the decodeString routine to reverse the encoding.

参数:
str -
返回:
String

decodeString

public static String decodeString(String str)
Decode a string using Base64 encoding.

参数:
str -
返回:
String

strEquals

public static boolean strEquals(String s,
                                String s1)

join

public static String join(Object[] aobj,
                          String s)

join

public static String join(Iterator iterator,
                          String s)

formatChineseString

public static String formatChineseString(String s)

trimToByteSize

public static String trimToByteSize(String s,
                                    String s1,
                                    int i)

objectEquals

public static boolean objectEquals(Object obj,
                                   Object obj1)

merge

public static String merge(String[] src,
                           String delimiter)
合并字符串数组为一个串

参数:
src - String[] 字符串数组
delimiter - 隔开字符
返回:
String

defaultString

public static String defaultString(String ab)

split

public static String[] split(String ext)

split

public static String[] split(String ext,
                             char pix)

isNullOrBank

public static boolean isNullOrBank(String ext)

isEmpty

public static boolean isEmpty(String ext)

split

public static String[] split(String str,
                             int sect,
                             int len)
                      throws Exception
分解字符串

参数:
str - String
sect - int 分解的段数
len - int 每段的字符长度
返回:
String[]
抛出:
Exception

URLEncode

public static String URLEncode(String srcStr,
                               String encoding)
对整个url进行编码转换

参数:
srcStr - url串
encoding - 编码
返回:
String

replace

public static final String replace(String line,
                                   String oldString,
                                   String newString)
用 newString 替换 line 中的所有的 OldString。 不支持正则表达式

参数:
line - 原字符串
oldString - 被替换的字符串
newString - 新的要替换oldString的字符串
返回:
返回所有oldString都被newString替换的字符串

replace

public static final String replace(String line,
                                   String oldString,
                                   String newString,
                                   int[] count)
用 newString 替换 line 中的所有的 OldString count返回被替换的数目

参数:
line - 原字符串
oldString - 被替换的字符串
newString - 新的要替换oldString的字符串
返回:
返回所有oldString都被newString替换的字符串

replaceIgnoreCase

public static final String replaceIgnoreCase(String line,
                                             String oldString,
                                             String newString)
做不区分大小写的模式匹配,并用newString 来替换 oldString

参数:
line - 原字符串
oldString - 被替换的字符串
newString - 新的要替换oldString的字符串
返回:
返回所有oldString都被newString替换的字符串

getStrIndex

public static int getStrIndex(String s,
                              String[] args)
从数组中得到字符串的位置

参数:
s - 要查询的字符串
args - 待查的数组
返回:
s的位置,没有找到就是-1

nullToEmpty

public static String nullToEmpty(String src)
判断 如果输入的字符为null或者'null',输出空字符串""

参数:
src -
返回:

toCamelCasing

public static String toCamelCasing(String s)
将下划线连接的String替换为驼峰风格

参数:
s -
返回:

lowerFirstChar

public static String lowerFirstChar(String s)
将首字母小写

参数:
s -
返回:

upperFirstChar

public static String upperFirstChar(String s)
将首字母大写

参数:
s -
返回:


Copyright © 2017. All Rights Reserved.