public class StringUtils
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
FILL_TYPE_LEFT
字符填充方向为在左边填充。
|
static int |
FILL_TYPE_LEFT_AND_RIGHT
字符填充方向为在左边和右边轮流填充,使有效字符处于中间。
|
static int |
FILL_TYPE_RIGHT
字符填充方向为在右边填充。
|
protected static org.slf4j.Logger |
log
日志对象。
|
| 构造器和说明 |
|---|
StringUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static java.util.Date |
addDate(java.util.Date date,
char type,
int cycle)
日期字符串时间加减计算。
|
static java.util.Date |
addDate(java.lang.String time,
char type,
int cycle)
日期字符串时间加减计算。
|
static java.lang.String |
ascii2Native(java.lang.String in)
把\\uXXXX格式的字符串转换成系统原生的字符串。
|
static java.lang.String |
ascii2Native(java.lang.String in,
java.lang.String encoding)
把\\uXXXX格式的字符串转换成系统原生的字符串。
|
static java.lang.String |
byteToUnsignedString(byte by,
int shift)
Convert the byte to an unsigned number.
|
static java.lang.String |
chopAtWord(java.lang.String string,
int length)
Intelligently chops a String at a word boundary (whitespace) that occurs
at the specified index in the argument or before.
|
static java.lang.String |
dateToMillis(java.util.Date date)
Formats a Date as a fifteen character long String made up of the Date's
padded millisecond value.
|
static java.lang.String |
decodeBase64(byte[] data)
Decodes a base64 aray of bytes.
|
static java.lang.String |
decodeBase64(java.lang.String data)
Decodes a base64 String.
|
static byte[] |
decodeHex(java.lang.String hex)
Turns a hex encoded string into a byte array.
|
static java.lang.String |
decodeJsUnicode(java.lang.String str)
对格式为 \\uXXXX 的JS Unicode字符串解码。
|
static java.lang.String |
delParameterFromQueryString(java.lang.String queryString,
java.lang.String parameterName)
从请求字符串中删除指定参数。
|
static java.lang.String |
encodeBase64(byte[] data)
Encodes a byte array into a base64 String.
|
static java.lang.String |
encodeBase64(java.lang.String data)
Encodes a String as a base64 String.
|
static java.lang.String |
encodeHex(byte[] bytes)
Turns an array of bytes into a String representing each byte as an
unsigned hex number.
|
static java.lang.String |
encodeJsUnicode(java.lang.String str)
编码为 \\uXXXX 的JS Unicode的字符串。
|
static java.lang.String |
escapeForJSON(java.lang.Object in)
进行JSON数据编码。
|
static java.lang.String |
escapeForJSON(java.lang.String in)
JSON字符串特殊字符编码。
|
static java.lang.String |
escapeForXML(java.lang.Object in)
进行XML数据编码。
|
static java.lang.String |
escapeForXML(java.lang.String in)
对字符串中需要编码的字符进行编码,使字符串可以用在XML文档中。
|
static java.lang.String |
escapeHTMLTags(java.lang.String in)
对内容为Html标签的字符串进行编码。
|
static byte[] |
getBytesUtf8(java.lang.String string)
Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte
array.
|
static java.lang.String |
hash(java.lang.String data)
Hashes a String using the Md5 algorithm and returns the result as a
String of hexadecimal numbers.
|
static boolean |
hasNoASCII(java.lang.String strIn)
判断是否有非ASCII字符。
|
static java.lang.String |
highlightWords(java.lang.String string,
java.lang.String[] words,
java.lang.String startHighlight,
java.lang.String endHighlight)
Highlights words in a string.
|
static boolean |
isContainNotAscii(java.lang.String in)
判断字符串是否包含非Ascii字符(如中文字符)。
|
static boolean |
isEmpty(java.lang.CharSequence cs)
Checks if a CharSequence is empty ("") or null.
|
static boolean |
isEmpty(java.lang.String in)
判读字符串是否为空字符串。
|
static boolean |
isFalse(java.lang.String val)
字符串是否为布尔型false的有效值。
|
static boolean |
isNotEmpty(java.lang.CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
|
static boolean |
isNumeric(java.lang.CharSequence cs)
判断是否为数字。
|
static boolean |
isTrue(java.lang.String val)
字符串是否为布尔型true的有效值。
|
static void |
main(java.lang.String[] args)
执行函数。
|
static java.lang.String |
native2Ascii(java.lang.String in)
把系统原生的字符串转换成\\uXXXX格式的字符串。
|
static java.lang.String |
newString(byte[] bytes,
java.lang.String charsetName)
Constructs a new
String by decoding the specified array of bytes using the given charset. |
static java.lang.String |
newStringUtf8(byte[] bytes)
Constructs a new
String by decoding the specified array of bytes using the UTF-8 charset. |
static java.lang.String |
normalizePath(java.lang.String path,
boolean replaceBackSlash)
Normalize a relative URI path that may have relative values ("/./",
"/../", and so on ) it it.
|
static java.lang.String |
numberToStr(double val,
int scale)
数字转换为带逗号分隔的字符串。
|
static java.lang.String |
numberToStr(double val,
int scale,
char delimiter)
数字转换为带特定字符分隔的字符串。
|
static java.lang.String |
numberToStr(double val,
int scale,
java.lang.String language)
数字转换为数字描述字符串。
|
static java.lang.String |
numberToStr(long val)
数字转换为带逗号分隔的字符串。
|
static java.lang.String |
numberToStr(long val,
int minLen)
数字转换为填充指定字符到达最小长度的字符串。
|
static java.lang.String |
numberToStr(long val,
int minLen,
char fillChar)
数字转换为填充指定字符到达最小长度的字符串。
|
static java.lang.String |
numberToStr(long val,
int minLen,
char fillChar,
int fillType)
数字转换为填充指定字符到达最小长度的字符串。
|
static java.lang.String |
numberToStr(long val,
java.lang.String language)
数字转换为数字描述字符串。
|
static java.lang.String |
randomString(int length)
Returns a random String of numbers and letters (lower and upper case) of
the specified length.
|
static java.lang.String[] |
removeCommonWords(java.lang.String[] words)
Returns a new String array with some of the most common English words
removed.
|
static java.lang.String |
replace(java.lang.String in,
java.lang.String[] oldStrings,
java.lang.String[] newStrings)
替换一组字符串。
|
static java.lang.String |
replace(java.lang.String in,
java.lang.String[] oldStrings,
java.lang.String[] newStrings,
boolean[] isIgnoreCase)
替换一组字符串。
|
static java.lang.String |
replace(java.lang.String in,
java.lang.String[] oldStrings,
java.lang.String[] newStrings,
boolean[] isIgnoreCase,
int[] retCount)
替换一组字符串。
|
static java.lang.String |
replace(java.lang.String toReplace,
java.lang.String find,
java.lang.String replaceTo)
Replaces all instances of oldString with newString in line.
|
static java.lang.String |
replace(java.lang.String line,
java.lang.String oldString,
java.lang.String newString,
int[] retCount)
Replaces all instances of oldString with newString in line.
|
static java.lang.String |
replaceIgnoreCase(java.lang.String line,
java.lang.String oldString,
java.lang.String newString)
Replaces all instances of oldString with newString in line with the added
feature that matches of newString in oldString ignore case.
|
static java.lang.String |
replaceIgnoreCase(java.lang.String line,
java.lang.String oldString,
java.lang.String newString,
int[] retCount)
Replaces all instances of oldString with newString in line with the added
feature that matches of newString in oldString ignore case.
|
static long |
strToFlow(java.lang.String str,
long scale)
流量大小的字符串转流量字节数数。
|
static int |
strToNumber(java.lang.String val,
int defVal,
java.lang.String radix)
字符串转数字。
|
static long |
strToNumber(java.lang.String val,
long defVal,
java.lang.String radix)
字符串转数字。
|
static long |
strToTime(java.lang.String str)
时间长度的字符串转毫秒数。
|
static java.lang.String |
timeFormat(java.util.Date time,
java.lang.String timeFormat)
格式化时间值为字符串。
|
static java.lang.String |
timeFormat(long time,
java.lang.String timeFormat)
格式化时间值为字符串。
|
static java.lang.String |
timeToStr(long time)
时间毫秒数转成时间字符串,如多少周,多少日,多少小时,多少分钟,多少秒,多少毫秒
|
static boolean |
toBool(java.lang.String value,
boolean defVal)
字符串值转布尔值。
|
static java.util.Date |
toDate(java.lang.Object val)
对象转日期对象。
|
static java.util.Date |
toDate(java.lang.String source)
时间字符串转成日期型。
|
static java.util.Date |
toDate(java.lang.String source,
java.lang.String format,
FixTimeType fixTime)
时间字符串转成日期型。
|
static long |
toDateLong(java.lang.String src)
时间字符串转成日期的长整型数 yyyy-MM-dd HH:mm:ss.S 等格式。
|
static double |
toDouble(java.lang.String value,
double defVal)
字符串值转浮点值。
|
static float |
toFloat(java.lang.String val,
float def)
字符串值转浮点值。
|
static int |
toInt(java.lang.String value,
int def)
字符串值转整型值。
|
static long |
toLong(java.lang.String value,
long defVal)
字符串值转长整型值。
|
static java.lang.String[] |
toLowerCaseWordArray(java.lang.String text)
Converts a line of text into an array of lower case words using a
BreakIterator.wordInstance().
|
static java.lang.String |
toNumberLetterString(byte[] bytes)
转换为由数字、字母、-和_组成的字符串。
|
static java.lang.String |
toString(java.lang.Object val)
对象转字符串。
|
static java.lang.String |
unescapeFromXML(java.lang.String string)
Unescapes the String by converting XML escape sequences back into normal
characters.
|
static java.lang.String |
zeroPadString(java.lang.String string,
int length)
Pads the supplied String with 0's to the specified length and returns the
result as a new String.
|
protected static final org.slf4j.Logger log
public static final int FILL_TYPE_LEFT
public static final int FILL_TYPE_RIGHT
public static final int FILL_TYPE_LEFT_AND_RIGHT
public static final java.lang.String replace(java.lang.String toReplace,
java.lang.String find,
java.lang.String replaceTo)
toReplace - the String to search to perform replacements onfind - the String that should be replaced by newStringreplaceTo - the String that will replace all instances of
oldStringpublic static final java.lang.String replaceIgnoreCase(java.lang.String line,
java.lang.String oldString,
java.lang.String newString)
line - the String to search to perform replacements onoldString - the String that should be replaced by newStringnewString - the String that will replace all instances of oldStringpublic static final java.lang.String replaceIgnoreCase(java.lang.String line,
java.lang.String oldString,
java.lang.String newString,
int[] retCount)
line - the String to search to perform replacements onoldString - the String that should be replaced by newStringnewString - the String that will replace all instances of oldStringretCount - a value that will be updated with the number of replaces
performed.public static final java.lang.String replace(java.lang.String line,
java.lang.String oldString,
java.lang.String newString,
int[] retCount)
line - the String to search to perform replacements onoldString - the String that should be replaced by newStringnewString - the String that will replace all instances of oldStringpublic static final java.lang.String replace(java.lang.String in,
java.lang.String[] oldStrings,
java.lang.String[] newStrings)
in - 输入字符串。oldStrings - 需要查找匹配的字符串数组。newStrings - 对应需要替换成的新字符串数组。public static final java.lang.String replace(java.lang.String in,
java.lang.String[] oldStrings,
java.lang.String[] newStrings,
boolean[] isIgnoreCase)
in - 输入字符串。oldStrings - 需要查找匹配的字符串数组。newStrings - 对应需要替换成的新字符串数组。isIgnoreCase - 是否忽略大小写。默认为不忽略大小写。public static final java.lang.String replace(java.lang.String in,
java.lang.String[] oldStrings,
java.lang.String[] newStrings,
boolean[] isIgnoreCase,
int[] retCount)
in - 输入字符串。oldStrings - 需要查找匹配的字符串数组。newStrings - 对应需要替换成的新字符串数组。isIgnoreCase - 是否忽略大小写。默认为不忽略大小写。retCount - 返回的被替换个数。输入为与输入字符串数组大小相同的整型数组。public static final java.lang.String escapeHTMLTags(java.lang.String in)
in - the text to be converted.public static final java.lang.String hash(java.lang.String data)
A hash is a one-way function -- that is, given an input, an output is easily computed. However, given the output, the input is almost impossible to compute. This is useful for passwords since we can store the hash and a hacker will then have a very hard time determining the original password.
every time a user logs in, we simply take their plain text password, compute the hash, and compare the generated hash to the stored hash. Since it is almost impossible that two passwords will generate the same hash, we know if the user gave us the correct password or not. The only negative to this system is that password recovery is basically impossible. Therefore, a reset password method is used instead.
data - the String to compute the hash of.public static final java.lang.String delParameterFromQueryString(java.lang.String queryString,
java.lang.String parameterName)
queryString - http请求字符串。parameterName - 要删除的参数名称。public static final java.lang.String encodeHex(byte[] bytes)
Method by Santeri Paavolainen, Helsinki Finland 1996
(c) Santeri Paavolainen, Helsinki Finland 1996
Distributed under LGPL.
hash - an array of bytes to convert to a hex-stringpublic static final byte[] decodeHex(java.lang.String hex)
hex - a hex encoded String to transform into a byte array.public static java.lang.String encodeJsUnicode(java.lang.String str)
str - public static java.lang.String decodeJsUnicode(java.lang.String str)
str - public static final java.lang.String encodeBase64(java.lang.String data)
data - a String to encode.public static final java.lang.String encodeBase64(byte[] data)
data - a byte array to encode.public static final java.lang.String decodeBase64(java.lang.String data)
data - a base64 encoded String to decode.the - decoded String.public static final java.lang.String decodeBase64(byte[] data)
data - a base64 encode byte array to decode.the - decoded String.public static final java.lang.String[] toLowerCaseWordArray(java.lang.String text)
This method is under the Open Source Software License.
text - a String of text to convert into an array of wordspublic static final java.lang.String[] removeCommonWords(java.lang.String[] words)
public static final java.lang.String randomString(int length)
The specified length must be at least one. If not, the method will return null.
length - the desired length of the random String to return.public static final java.lang.String chopAtWord(java.lang.String string,
int length)
length, the String will be
chopped there. If no newline or whitespace is found in
string up to the index length, the String
will chopped at length.
For example, chopAtWord("This is a nice String", 10) will return "This is a" which is the first word boundary less than or equal to 10 characters into the original String.
string - the String to chop.length - the index in string to start looking for a
whitespace boundary at.string whose length is less than or
equal to length, and that is chopped at
whitespace.public static final java.lang.String highlightWords(java.lang.String string,
java.lang.String[] words,
java.lang.String startHighlight,
java.lang.String endHighlight)
This method is under the Open Source Software License.
string - the String to highlight words in.words - an array of words that should be highlighted in the string.startHighlight - the tag that should be inserted to start
highlighting.endHighlight - the tag that should be inserted to end highlighting.public static final java.lang.String escapeForJSON(java.lang.Object in)
in - public static final java.lang.String escapeForJSON(java.lang.String in)
theString = theString.Replace(">", ">");
theString = theString.Replace("<", "<");
theString = theString.Replace(" ", " ");
theString = theString.Replace("\"", """);
theString = theString.Replace("\'", "'");
theString = theString.Replace("\\", "\\\\");//对斜线的转义
theString = theString.Replace("\n", "\\n");
theString = theString.Replace("\r", "\\r");
in - public static final java.lang.String escapeForXML(java.lang.Object in)
in - public static final java.lang.String escapeForXML(java.lang.String in)
string - the string to escape.public static final java.lang.String unescapeFromXML(java.lang.String string)
string - the string to unescape.public static final java.lang.String zeroPadString(java.lang.String string,
int length)
string - the original String to pad.length - the desired length of the new padded String.public static java.util.Date addDate(java.lang.String time,
char type,
int cycle)
time - 原始时间字符串。type - 计算时间周期类型。Y为年;M为月;W为周;D为日(默认);H为小时;N为分钟。cycle - 加或减的时间周期数。负值为减时间。Util.getNextMonthTime(long),
Util.getNextTime(long, int, int),
Util.getNextYearTime(long),
addDate(String, char, int)public static java.util.Date addDate(java.util.Date date,
char type,
int cycle)
date - 原始时间。type - 计算时间周期类型。Y为年;M为月;W为周;D为日(默认);H为小时;N为分钟。cycle - 加或减的时间周期数。负值为减时间。Util.getNextMonthTime(long),
Util.getNextTime(long, int, int),
Util.getNextYearTime(long),
addDate(String, char, int)public static final java.lang.String dateToMillis(java.util.Date date)
public static final long strToNumber(java.lang.String val,
long defVal,
java.lang.String radix)
val - 字符串。defVal - 默认值。注意如果是常量应该给后缀L,防止调用了转换为整型的方法。如默认值-1时,代码写: -1L。radix - 进制字符串。如按16进制读取为:"16"。可指定多个进制,如先按10进制读取,若失败再按16进制读取为:"10,16"public static final int strToNumber(java.lang.String val,
int defVal,
java.lang.String radix)
val - 字符串。defVal - 默认值。radix - 进制字符串。如按16进制读取为:"16"。可指定多个进制,如先按10进制读取,若失败再按16进制读取为:"10,16"public static final java.lang.String timeFormat(long time,
java.lang.String timeFormat)
time - 时间值。timeFormat - 时间格式化化字符串。如:"yyyy-MM-dd HH:mm:ss.S"public static final java.lang.String timeFormat(java.util.Date time,
java.lang.String timeFormat)
time - 时间值。timeFormat - 时间格式化化字符串。如:"yyyy-MM-dd HH:mm:ss.S"。默认采用:"yyyy-MM-dd HH:mm:ss"public static final java.lang.String timeToStr(long time)
time - longpublic static final long strToTime(java.lang.String str)
str - public static final long strToFlow(java.lang.String str,
long scale)
str - scale - 倍数,默认为1024。public static boolean toBool(java.lang.String value,
boolean defVal)
value - defVal - public static double toDouble(java.lang.String value,
double defVal)
value - defVal - public static float toFloat(java.lang.String val,
float def)
val - def - public static int toInt(java.lang.String value,
int def)
value - def - public static long toLong(java.lang.String value,
long defVal)
value - defVal - public static final java.util.Date toDate(java.lang.Object val)
val - public static final java.util.Date toDate(java.lang.String source)
支持格式: "yyyy-MM-dd'T'HH:mm:ss.S" "yyyy-MM-dd HH:mm:ss.S" "yyyy-MM-dd HH:mm:ss" "yyyyMMddHHmmss" "yyyy-MM-dd" "yyyyMMdd" "yyyyMd" "yyyyMd" "yyyy-M-d H:m:s.S" "yyyy-M-d H:m:s" "yyyy-M-d H:m" "yyyy-M-d H" "yyyy-M-d" "yyyy年M月d日 H时m分s秒" "yyyy年M月d日 H时m分" "yyyy年M月d日 H时" "yyyy年M月d日" "EEE MMM dd HH:mm:ss zzz yyyy" "M/d/yyyy H:m:s.S" "M/d/yyyy HH:mm:ss" "M/d/yyyy HH:mm" "M/d/yyyy" "EEE MMM dd HH:mm:ss zzz yyyy" 等。
source - String#toDateLong(),
g_stringToDateFormats,
g_stringToDateFixFormatspublic static final java.util.Date toDate(java.lang.String source,
java.lang.String format,
FixTimeType fixTime)
format 为空时的默认转换格式: 支持格式: yyyy-M-d H:m:s.S yyyy-M-d H:m:s yyyy-M-d H:m yyyy-M-d H yyyy-M-d yyyy年M月d日 H时m分s秒 yyyy年M月d日 H时m分 yyyy年M月d日 H时 yyyy年M月d日 EEE MMM dd HH:mm:ss zzz yyyy M/d/yyyy H:m:s.S M/d/yyyy HH:mm:ss M/d/yyyy HH:mm M/d/yyyy yyyyMMdd 等。
source - 时间字符串。format - 时间格式。fixTime - 是否包含当天全天。
FixIncludeOneDayType.FIX_ALL_TIME 始终调整到当天最后时刻
FixIncludeOneDayType.FIX_DAY_BEGIN_ONLY 只有时间字符串中不包含时刻时调整为当前最后时刻。
FixIncludeOneDayType.FIX_NONE 始终不调整。(默认方式)#toDateLong(),
g_stringToDateFormats,
g_stringToDateFixFormatspublic static final long toDateLong(java.lang.String src)
支持格式: yyyy-M-d H:m:s.S yyyy-M-d H:m:s yyyy-M-d H:m yyyy-M-d H yyyy-M-d yyyy年M月d日 H时m分s秒 yyyy年M月d日 H时m分 yyyy年M月d日 H时 yyyy年M月d日 EEE MMM dd HH:mm:ss zzz yyyy M/d/yyyy H:m:s.S M/d/yyyy HH:mm:ss M/d/yyyy HH:mm M/d/yyyy yyyyMMdd 等。
src - StringtoDate(String),
toDate(String, String, FixTimeType),
g_stringToDateFormats,
g_stringToDateFixFormatspublic static final java.lang.String toString(java.lang.Object val)
val - public static final boolean isContainNotAscii(java.lang.String in)
in - 输入的字符串。public static final boolean isEmpty(java.lang.String in)
in - 输入的字符串。public static boolean isEmpty(java.lang.CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true
StringUtils.isEmpty("") = true
StringUtils.isEmpty(" ") = false
StringUtils.isEmpty("bob") = false
StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0. It no longer trims the CharSequence. That functionality is available in isBlank().
cs - the CharSequence to check, may be nulltrue if the CharSequence is empty or nullpublic static boolean isNotEmpty(java.lang.CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false
StringUtils.isNotEmpty("") = false
StringUtils.isNotEmpty(" ") = true
StringUtils.isNotEmpty("bob") = true
StringUtils.isNotEmpty(" bob ") = true
cs - the CharSequence to check, may be nulltrue if the CharSequence is not empty and not nullpublic static final boolean isTrue(java.lang.String val)
val - public static final boolean isFalse(java.lang.String val)
val - public static boolean isNumeric(java.lang.CharSequence cs)
cs - public static final java.lang.String native2Ascii(java.lang.String in)
in - native stringpublic static final java.lang.String numberToStr(double val,
int scale)
val - 浮点数。scale - 小数点位数。public static final java.lang.String numberToStr(double val,
int scale,
char delimiter)
val - 浮点数。scale - 小数点位数。delimiter - 每3位插入的分隔字符,指定值为0时不插入字符。public static final java.lang.String numberToStr(double val,
int scale,
java.lang.String language)
val - 浮点数。scale - 小数点位数。language - 语言。中文为cnpublic static final java.lang.String numberToStr(long val)
val - 整型数。public static final java.lang.String numberToStr(long val,
int minLen)
val - 整型数。minLen - 最小长度。FILL_TYPE_LEFT,
FILL_TYPE_RIGHT,
FILL_TYPE_LEFT_AND_RIGHTpublic static final java.lang.String numberToStr(long val,
int minLen,
char fillChar)
val - 整型数。minLen - 最小长度。fillChar - 填充的字符。FILL_TYPE_LEFT,
FILL_TYPE_RIGHT,
FILL_TYPE_LEFT_AND_RIGHTpublic static final java.lang.String numberToStr(long val,
int minLen,
char fillChar,
int fillType)
val - 整型数。minLen - 最小长度。fillChar - 填充的字符。fillType - 填充方向。FILL_TYPE_LEFT,
FILL_TYPE_RIGHT,
FILL_TYPE_LEFT_AND_RIGHTpublic static final java.lang.String numberToStr(long val,
java.lang.String language)
val - 整型数。language - 语言。中文为cnpublic static final java.lang.String ascii2Native(java.lang.String in)
in - ascii stringpublic static final java.lang.String ascii2Native(java.lang.String in,
java.lang.String encoding)
in - ascii stringencoding - 字符编码,null为系统默认编码。public static java.lang.String normalizePath(java.lang.String path,
boolean replaceBackSlash)
path - Relative path to be normalizedreplaceBackSlash - Should '\\' be replaced with '/'public static java.lang.String toNumberLetterString(byte[] bytes)
bytes - public static boolean hasNoASCII(java.lang.String strIn)
strIn - 输入字符串。public static void main(java.lang.String[] args)
args - public static java.lang.String byteToUnsignedString(byte by,
int shift)
public static java.lang.String newString(byte[] bytes,
java.lang.String charsetName)
String by decoding the specified array of bytes using the given charset.
This method catches UnsupportedEncodingException and re-throws it as IllegalStateException, which
should never happen for a required charset name. Use this method when the encoding is required to be in the JRE.
bytes - The bytes to be decoded into characters, may be nullcharsetName - The name of a required CharsetString decoded from the specified array of bytes using the given charset,
or null if the input byte array was null.java.lang.IllegalStateException - Thrown when a UnsupportedEncodingException is caught, which should never happen for a
required charset name.CharEncoding,
String.String(byte[], String)public static java.lang.String newStringUtf8(byte[] bytes)
String by decoding the specified array of bytes using the UTF-8 charset.bytes - The bytes to be decoded into charactersString decoded from the specified array of bytes using the UTF-8 charset,
or null if the input byte array was null.java.lang.NullPointerException - Thrown if Charsets#UTF_8 is not initialized, which should never happen since it is
required by the Java platform specification.NullPointerException instead of UnsupportedEncodingExceptionpublic static byte[] getBytesUtf8(java.lang.String string)
string - the String to encode, may be nullnull if the input string was nulljava.lang.NullPointerException - Thrown if Charsets#UTF_8 is not initialized, which should never happen since it is
required by the Java platform specification.NullPointerException instead of UnsupportedEncodingException#getBytesUnchecked(String, String)Copyright © 2001-2014 hynnet.com