public final class StringUtility extends Object
Title: 常用代码打包
Description: 字符串操作常用的方法
Copyright: Copyright (c) 2002-12-5
Company: www.justdos.net
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
base64ToBytes(String s) |
static String |
bytesToBase64(byte[] abyte0) |
static char |
byteToChar(byte[] b) |
static double |
byteToDouble(byte[] b) |
static int |
byteToInt(byte[] b) |
static byte[] |
charToByte(char ch) |
static String |
convertCastChar(String src)
转义数据库通配字符:'%','_' Creation date: (2000-12-20 14:49:55)
|
static String |
convertForHtml(String src)
转换常见的Html符号 Creation date: (2000-12-20 14:58:19)
|
static String |
convertForXml(String src)
Insert the method's description here.
|
static String |
convertSingleQuot(String src)
转义单引号 Creation date: (2000-12-20 14:43:29)
|
static String |
createRandom(boolean numberFlag,
int length)
创建指定数量的随机字符串
|
static byte[] |
doubleToByte(double d) |
static String |
escapeHTMLSpecial(String str)
将一个字符串中带有的HTML特殊字符转换为HTML的转义字符。
|
static String |
escapeJSSpecial(String str)
将一个字符串中带有的JS特殊字符转换为JS的转义字符。
|
static String |
escapeSQLSpecial(String str)
将一个字符串中带有的SQL特殊字符转换为转义字符。
|
static String |
filterNull(String str)
如果是null字符串, 则返回""字符串
|
static String |
filterNullObject(Object obj)
如果是null对象, 则返回""字符串
|
static String |
formatJavaName(String name,
boolean firstCharUpperCase)
格式化以下划线'_'或减号'-'隔开的字符串,如:
"user-name", 可以格式化为"userName"
|
static String |
formatNumber(double number,
int decimalDigits)
格式化double类型数字 保留decimalDigits位小数
|
static String |
formatNumber(float number,
int decimalDigits)
格式化float类型数字 保留decimalDigits位小数
|
static String |
formatNumber(String number,
int decimalDigits)
格式化String类型数字 保留decimalDigits位小数
|
static String |
getGetMethodName(String name) |
static String |
getIsMethodName(String name) |
static String |
getMoreString(String str,
int maxByteLength,
String more)
获得截取到指定字节长度后的字符串,多出部分用指定字符串代替。
|
static String |
getSetMethodName(String name) |
static byte[] |
intToByte(int number) |
static String |
replace(String original,
String oldString,
String newString)
Replace substrings of one string with another string and return altered string.
|
static String |
replace(String original,
String oldString,
String newString,
int counts)
Replace substrings of one string with another string and return altered string.
|
static String[] |
split(String sourceString,
String delim)
把由delim分割的字符串分裂并形成字符串数组。
|
public static String convertSingleQuot(String src)
src - java.lang.Stringpublic static String createRandom(boolean numberFlag, int length)
numberFlag - 是否是数字length - public static String convertCastChar(String src)
src - java.lang.Stringpublic static String convertForHtml(String src)
src - java.lang.Stringpublic static String convertForXml(String src)
public static String filterNull(String str)
str - Stringpublic static String filterNullObject(Object obj)
obj - Objectpublic static String replace(String original, String oldString, String newString)
original - input stringoldString - the substring section to replacenewString - the new substring replacing old substring sectionpublic static String replace(String original, String oldString, String newString, int counts)
original - input stringoldString - the substring section to replacenewString - the new substring replacing old substring sectioncounts - how many times the replace happen, 0 for all.public static String escapeHTMLSpecial(String str)
str - 要进行HTML特殊字符串转义的字符串public static String escapeJSSpecial(String str)
str - 要进行JS特殊字符串转义的字符串public static String escapeSQLSpecial(String str)
str - 要进行SQL特殊字符串转义的字符串public static String getMoreString(String str, int maxByteLength, String more)
str - 需要限定长度的字符串maxByteLength - 最大字节数more - 超长情况的替换字符串public static String[] split(String sourceString, String delim)
sourceString - 要分裂的字符串delim - 分隔符public static byte[] intToByte(int number)
public static int byteToInt(byte[] b)
public static byte[] charToByte(char ch)
public static char byteToChar(byte[] b)
public static byte[] doubleToByte(double d)
public static double byteToDouble(byte[] b)
public static final byte[] base64ToBytes(String s)
public static final String bytesToBase64(byte[] abyte0)
public static String formatNumber(double number, int decimalDigits)
number - 要格式化的double数字decimalDigits - 保留小数位数public static String formatNumber(float number, int decimalDigits)
number - 要格式化的float数字decimalDigits - 保留小数位数public static String formatNumber(String number, int decimalDigits)
number - 要格式化的String数字decimalDigits - 保留小数位数public static final String formatJavaName(String name, boolean firstCharUpperCase)
name - java.lang.StringfirstCharUpperCase - boolean 如果为true,那么返回的首字母大写,反之,小写Copyright © 2023 onecode. All rights reserved.