/**********************************************************
* 函数名: GetDataBaseLength
* 机能概要: 判断字符串的数据库长度
*
* 参数: strin 待判字符串
* 返回值: Int 长度
*********************************************************/ public static int GetDataBaseLength(String strin)
{
byte[] b = strin.getBytes();
return b.length;
}
/**********************************************************
* 函数名 :GetDataBaseLengthCase
* 机能概要 :判断字符串的数据库长度
* (全角与半角总和)
* 参数 :inStr 待判字符串
* 参数 :len JSP中该字符串的上限
* 返回值 :boolean
**********************************************************/ public static boolean GetDataBaseLengthCase(String inStr, int len)
{
try{
byte[] b = inStr.getBytes();
if (b.length > len) {
return false;
}
}catch(Exception e){
System.out.println("GetDataBaseLengthCase" + e);
}
return true;
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12379366/viewspace-85557/
,如需转载,请注明出处,否则将追究法律责任。