java自定义3个类型,用list怎么封装多个list生成xml导入硬盘

&* all rights reserved by zhanqiong, 2005
package com.koubei.
import java.beans.XMLD
import java.io.BufferedInputS
import java.io.ByteArrayInputS
import java.io.UnsupportedEncodingE
import java.net.URLE
import java.text.DecimalF
import java.util.ArrayL
import java.util.HashM
import java.util.HashS
import java.util.I
import java.util.LinkedHashM
import java.util.L
import java.util.M
import java.util.S
import java.util.regex.M
import java.util.regex.P
import mons.lang.RandomStringU
import mons.logging.L
import mons.logging.LogF
import com.opensymphony.util.TextU
&* @author chen
public class StringUtil {
&&&&private static Pattern numericPattern = pile(&^[0-9\\-]+$&);
&&&&private static Pattern numericStringPattern = Pattern
&&&&&&&&&&&&.compile(&^[0-9\\-\\-]+$&);
&&&&private static Pattern floatNumericPattern = Pattern
&&&&&&&&&&&&.compile(&^[0-9\\-\\.]+$&);
&&&&private static Pattern abcPattern = pile(&^[a-z|A-Z]+$&);
&&&&public static final String splitStrPattern = &,|,|;|;|、|\\.|。|-|_|\\(|\\)|\\[|\\]|\\{|\\}|\\\\|/| | |\&&;
&&&&private static Log logger = LogFactory.getLog(StringUtil.class);
&&&&&* 判断是否数字表示
&&&&&* @param src
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @return 是否数字的标志
&&&&public static boolean isNumeric(String src) {
&&&&&&&&boolean return_value = false;
&&&&&&&&if (src != null && src.length() & 0) {
&&&&&&&&&&&&Matcher m = numericPattern.matcher(src);
&&&&&&&&&&&&if (m.find()) {
&&&&&&&&&&&&&&&&return_value = true;
&&&&&&&&&&&&}
&&&&&&&&return return_
&&&&&* 判断是否数字表示
&&&&&* @param src
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @return 是否数字的标志
&&&&public static boolean isNumericString(String src) {
&&&&&&&&boolean return_value = false;
&&&&&&&&if (src != null && src.length() & 0) {
&&&&&&&&&&&&Matcher m = numericStringPattern.matcher(src);
&&&&&&&&&&&&if (m.find()) {
&&&&&&&&&&&&&&&&return_value = true;
&&&&&&&&&&&&}
&&&&&&&&return return_
&&&&&* 判断是否纯字母组合
&&&&&* @param src
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @return 是否纯字母组合的标志
&&&&public static boolean isABC(String src) {
&&&&&&&&boolean return_value = false;
&&&&&&&&if (src != null && src.length() & 0) {
&&&&&&&&&&&&Matcher m = abcPattern.matcher(src);
&&&&&&&&&&&&if (m.find()) {
&&&&&&&&&&&&&&&&return_value = true;
&&&&&&&&&&&&}
&&&&&&&&return return_
&&&&&* 判断是否浮点数字表示
&&&&&* @param src
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @return 是否数字的标志
&&&&public static boolean isFloatNumeric(String src) {
&&&&&&&&boolean return_value = false;
&&&&&&&&if (src != null && src.length() & 0) {
&&&&&&&&&&&&Matcher m = floatNumericPattern.matcher(src);
&&&&&&&&&&&&if (m.find()) {
&&&&&&&&&&&&&&&&return_value = true;
&&&&&&&&&&&&}
&&&&&&&&return return_
&&&&&* 把string array or list用给定的符号symbol连接成一个字符串
&&&&&* @param array
&&&&&* @param symbol
&&&&&* @return
&&&&public static String joinString(List array, String symbol) {
&&&&&&&&String result = &&;
&&&&&&&&if (array != null) {
&&&&&&&&&&&&for (int i = 0; i & array.size(); i++) {
&&&&&&&&&&&&&&&&String temp = array.get(i).toString();
&&&&&&&&&&&&&&&&if (temp != null && temp.trim().length() & 0)
&&&&&&&&&&&&&&&&&&&&result += (temp + symbol);
&&&&&&&&&&&&}
&&&&&&&&&&&&if (result.length() & 1)
&&&&&&&&&&&&&&&&result = result.substring(0, result.length() - 1);
&&&&&&&&return
&&&&public static String subStringNotEncode(String subject, int size) {
&&&&&&&&if (subject != null && subject.length() & size) {
&&&&&&&&&&&&subject = subject.substring(0, size) + &...&;
&&&&&&&&return
&&&&public static String subString(String subject, int size) {
&&&&&&&&subject = TextUtils.htmlEncode(subject);
&&&&&&&&if (subject.length() & size) {
&&&&&&&&&&&&subject = subject.substring(0, size) + &...&;
&&&&&&&&return
&&&&&* 截取字符串 超出的字符用symbol代替   
&&&&&* @param len
&&&&&*&&&&&&&&&&&  字符串长度 长度计量单位为一个GBK汉字  两个英文字母计算为一个单位长度
&&&&&* @param str
&&&&&* @param symbol
&&&&&* @return
&&&&public static String getLimitLengthString(String str, int len, String symbol) {
&&&&&&&&int iLen = len * 2;
&&&&&&&&int counterOfDoubleByte = 0;
&&&&&&&&String strRet = &&;
&&&&&&&&try {
&&&&&&&&&&&&if (str != null) {
&&&&&&&&&&&&&&&&byte[] b = str.getBytes(&GBK&);
&&&&&&&&&&&&&&&&if (b.length &= iLen) {
&&&&&&&&&&&&&&&&&&&&return
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&for (int i = 0; i & iL i++) {
&&&&&&&&&&&&&&&&&&&&if (b[i] & 0) {
&&&&&&&&&&&&&&&&&&&&&&&&counterOfDoubleByte++;
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&if (counterOfDoubleByte % 2 == 0) {
&&&&&&&&&&&&&&&&&&&&strRet = new String(b, 0, iLen, &GBK&) +
&&&&&&&&&&&&&&&&&&&&return strR
&&&&&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&&&&&strRet = new String(b, 0, iLen - 1, &GBK&) +
&&&&&&&&&&&&&&&&&&&&return strR
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&return &&;
&&&&&&&&&&&&}
&&&&&&&&} catch (Exception ex) {
&&&&&&&&&&&&return str.substring(0, len);
&&&&&&&&} finally {
&&&&&&&&&&&&strRet = null;
&&&&&* 截取字符串 超出的字符用symbol代替   
&&&&&* @param len
&&&&&*&&&&&&&&&&&  字符串长度 长度计量单位为一个GBK汉字  两个英文字母计算为一个单位长度
&&&&&* @param str
&&&&&* @param symbol
&&&&&* @return12
&&&&public static String getLimitLengthString(String str, int len) {
&&&&&&&&return getLimitLengthString(str, len, &...&);
&&&&public static String subStr(String subject, int size) {
&&&&&&&&subject = TextUtils.htmlEncode(subject);
&&&&&&&&if (subject.length() & size) {
&&&&&&&&&&&&subject = subject.substring(0, size);
&&&&&&&&return
&&&&&* 截取字符,不转码
&&&&&* @param subject
&&&&&* @param size
&&&&&* @return
&&&&public static String subStrNotEncode(String subject, int size) {
&&&&&&&&if (subject.length() & size) {
&&&&&&&&&&&&subject = subject.substring(0, size);
&&&&&&&&return
&&&&&* 把string array or list用给定的符号symbol连接成一个字符串
&&&&&* @param array
&&&&&* @param symbol
&&&&&* @return
&&&&public static String joinString(String[] array, String symbol) {
&&&&&&&&String result = &&;
&&&&&&&&if (array != null) {
&&&&&&&&&&&&for (int i = 0; i & array. i++) {
&&&&&&&&&&&&&&&&String temp = array[i];
&&&&&&&&&&&&&&&&if (temp != null && temp.trim().length() & 0)
&&&&&&&&&&&&&&&&&&&&result += (temp + symbol);
&&&&&&&&&&&&}
&&&&&&&&&&&&if (result.length() & 1)
&&&&&&&&&&&&&&&&result = result.substring(0, result.length() - 1);
&&&&&&&&return
&&&&&* 取得字符串的实际长度(考虑了汉字的情况)
&&&&&* @param SrcStr
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @return 字符串的实际长度
&&&&public static int getStringLen(String SrcStr) {
&&&&&&&&int return_value = 0;
&&&&&&&&if (SrcStr != null) {
&&&&&&&&&&&&char[] theChars = SrcStr.toCharArray();
&&&&&&&&&&&&for (int i = 0; i & theChars. i++) {
&&&&&&&&&&&&&&&&return_value += (theChars[i] &= 255) ? 1 : 2;
&&&&&&&&&&&&}
&&&&&&&&return return_
&&&&&* 检查联系人信息是否填写,电话,手机,email必须填至少一个,email填了的话检查格式
&&&&&* @param phoneCity
&&&&&* @param phoneNumber
&&&&&* @param phoneExt
&&&&&* @param mobileNumber
&&&&&* @param email
&&&&&* @return
&&&&public static boolean checkContactInfo(String phoneCity,
&&&&&&&&&&&&String phoneNumber, String phoneExt, String mobileNumber,
&&&&&&&&&&&&String email) {
&&&&&&&&String result = (phoneCity == null ? && : phoneCity.trim())
&&&&&&&&&&&&&&&&+ (phoneNumber == null ? && : phoneNumber.trim())
&&&&&&&&&&&&&&&&+ (phoneExt == null ? && : phoneExt.trim())
&&&&&&&&&&&&&&&&+ (mobileNumber == null ? && : mobileNumber.trim())
&&&&&&&&&&&&&&&&+ (email == null ? && : email.trim());
&&&&&&&&if (result.length() & 1)
&&&&&&&&&&&&return false;
&&&&&&&&if (!isEmail(email))
&&&&&&&&&&&&return false;
&&&&&&&&return true;
&&&&&* 检查数据串中是否包含非法字符集
&&&&&* @param str
&&&&&* @return [true]|[false] 包含|不包含
&&&&public static boolean check(String str) {
&&&&&&&&String sIllegal = &'\&&;
&&&&&&&&int len = sIllegal.length();
&&&&&&&&if (null == str)
&&&&&&&&&&&&return false;
&&&&&&&&for (int i = 0; i & i++) {
&&&&&&&&&&&&if (str.indexOf(sIllegal.charAt(i)) != -1)
&&&&&&&&&&&&&&&&return true;
&&&&&&&&return false;
&&&&/***************************************************************************
&&&&&* getHideEmailPrefix - 隐藏邮件地址前缀。
&&&&&* @param email
&&&&&*&&&&&&&&&&& - EMail邮箱地址 例如:
&&&&&* @return 返回已隐藏前缀邮件地址, 如 *********@.
&&&&&* @version 1.0 () Wilson Lin
&&&&&**************************************************************************/
&&&&public static String getHideEmailPrefix(String email) {
&&&&&&&&if (null != email) {
&&&&&&&&&&&&int index = email.lastIndexOf('@');
&&&&&&&&&&&&if (index & 0) {
&&&&&&&&&&&&&&&&email = repeat(&*&, index).concat(email.substring(index));
&&&&&&&&&&&&}
&&&&&&&&return
&&&&/***************************************************************************
&&&&&* repeat - 通过源字符串重复生成N次组成新的字符串。
&&&&&* @param src
&&&&&*&&&&&&&&&&& - 源字符串 例如: 空格(& &), 星号(&*&), &浙江& 等等...
&&&&&* @param num
&&&&&*&&&&&&&&&&& - 重复生成次数
&&&&&* @return 返回已生成的重复字符串
&&&&&* @version 1.0 () Wilson Lin
&&&&&**************************************************************************/
&&&&public static String repeat(String src, int num) {
&&&&&&&&StringBuffer s = new StringBuffer();
&&&&&&&&for (int i = 0; i & i++)
&&&&&&&&&&&&s.append(src);
&&&&&&&&return s.toString();
&&&&&* 检查是否是email, when null or '' return true
&&&&&* @param email
&&&&&* @return
&&&&public static boolean isEmail(String email) {
&&&&&&&&if (email != null && email.trim().length() & 0) {
&&&&&&&&&&&&if (!TextUtils.verifyEmail(email)) {
&&&&&&&&&&&&&&&&return false;
&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&return true;
&&&&&&&&&&&&}
&&&&&&&&return false;
&&&&&* 根据指定的字符把源字符串分割成一个数组
&&&&&* @param src
&&&&&* @return
&&&&public static List&String& parseString2ListByCustomerPattern(
&&&&&&&&&&&&String pattern, String src) {
&&&&&&&&if (src == null)
&&&&&&&&&&&&return null;
&&&&&&&&List&String& list = new ArrayList&String&();
&&&&&&&&String[] result = src.split(pattern);
&&&&&&&&for (int i = 0; i & result. i++) {
&&&&&&&&&&&&list.add(result[i]);
&&&&&&&&return
&&&&&* 根据指定的字符把源字符串分割成一个数组
&&&&&* @param src
&&&&&* @return
&&&&public static List&String& parseString2ListByPattern(String src) {
&&&&&&&&String pattern = &,|,|、|。&;
&&&&&&&&return parseString2ListByCustomerPattern(pattern, src);
&&&&&* 格式化一个float
&&&&&* @param format
&&&&&*&&&&&&&&&&& 要格式化成的格式 such as #.00, #.#
&&&&public static String formatFloat(float f, String format) {
&&&&&&&&DecimalFormat df = new DecimalFormat(format);
&&&&&&&&return df.format(f);
&&&&&* 判断是否是空字符串 null和&& 都返回 true
&&&&&* @author Robin Chang
&&&&&* @param s
&&&&&* @return
&&&&public static boolean isEmpty(String s) {
&&&&&&&&if (s != null && !s.equals(&&)) {
&&&&&&&&&&&&return false;
&&&&&&&&return true;
&&&&&* 自定义的分隔字符串函数 例如: 1,2,3 =&[1,2,3] 3个元素 ,2,3=&[,2,3] 3个元素 ,2,3,=&[,2,3,]
&&&&&* 4个元素 ,,,=&[,,,] 4个元素
&&&&&* 5.22算法修改,为提高速度不用正则表达式 两个间隔符,,返回&&元素
&&&&&* @param split
&&&&&*&&&&&&&&&&& 分割字符 默认,
&&&&&* @param src
&&&&&*&&&&&&&&&&& 输入字符串
&&&&&* @return 分隔后的list
&&&&&* @author Robin
&&&&public static List&String& splitToList(String split, String src) {
&&&&&&&&String sp = &,&;
&&&&&&&&if (split != null && split.length() == 1) {
&&&&&&&&&&&&sp =
&&&&&&&&List&String& r = new ArrayList&String&();
&&&&&&&&int lastIndex = -1;
&&&&&&&&int index = src.indexOf(sp);
&&&&&&&&if (-1 == index && src != null) {
&&&&&&&&&&&&r.add(src);
&&&&&&&&&&&&return r;
&&&&&&&&while (index &= 0) {
&&&&&&&&&&&&if (index & lastIndex) {
&&&&&&&&&&&&&&&&r.add(src.substring(lastIndex + 1, index));
&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&r.add(&&);
&&&&&&&&&&&&}
&&&&&&&&&&&&lastIndex =
&&&&&&&&&&&&index = src.indexOf(sp, index + 1);
&&&&&&&&&&&&if (index == -1) {
&&&&&&&&&&&&&&&&r.add(src.substring(lastIndex + 1, src.length()));
&&&&&&&&&&&&}
&&&&&&&&return r;
&&&&&* 把 名=值 参数表转换成字符串 (a=1,b=2 =&a=1&b=2)
&&&&&* @param map
&&&&&* @return
&&&&public static String linkedHashMapToString(LinkedHashMap&String, String& map) {
&&&&&&&&if (map != null && map.size() & 0) {
&&&&&&&&&&&&String result = &&;
&&&&&&&&&&&&Iterator it = map.keySet().iterator();
&&&&&&&&&&&&while (it.hasNext()) {
&&&&&&&&&&&&&&&&String name = (String) it.next();
&&&&&&&&&&&&&&&&String value = (String) map.get(name);
&&&&&&&&&&&&&&&&result += (result.equals(&&)) ? && : &&&;
&&&&&&&&&&&&&&&&result += String.format(&%s=%s&, name, value);
&&&&&&&&&&&&}
&&&&&&&&&&&&return
&&&&&&&&return null;
&&&&&* 解析字符串返回 名称=值的参数表 (a=1&b=2 =& a=1,b=2)
&&&&&* @see test.koubei.util.StringUtilTest#testParseStr()
&&&&&* @param str
&&&&&* @return
&&&&@SuppressWarnings(&unchecked&)
&&&&public static LinkedHashMap&String, String& toLinkedHashMap(String str) {
&&&&&&&&if (str != null && !str.equals(&&) && str.indexOf(&=&) & 0) {
&&&&&&&&&&&&LinkedHashMap result = new LinkedHashMap();
&&&&&&&&&&&&String name = null;
&&&&&&&&&&&&String value = null;
&&&&&&&&&&&&int i = 0;
&&&&&&&&&&&&while (i & str.length()) {
&&&&&&&&&&&&&&&&char c = str.charAt(i);
&&&&&&&&&&&&&&&&switch (c) {
&&&&&&&&&&&&&&&&case 61:
&&&&&&&&&&&&&&&&&&&&value = &&;
&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&case 38:
&&&&&&&&&&&&&&&&&&&&if (name != null && value != null && !name.equals(&&)) {
&&&&&&&&&&&&&&&&&&&&&&&&result.put(name, value);
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&name = null;
&&&&&&&&&&&&&&&&&&&&value = null;
&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&default:
&&&&&&&&&&&&&&&&&&&&if (value != null) {
&&&&&&&&&&&&&&&&&&&&&&&&value = (value != null) ? (value + c) : && +
&&&&&&&&&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&&&&&&&&&name = (name != null) ? (name + c) : && +
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&i++;
&&&&&&&&&&&&}
&&&&&&&&&&&&if (name != null && value != null && !name.equals(&&)) {
&&&&&&&&&&&&&&&&result.put(name, value);
&&&&&&&&&&&&}
&&&&&&&&&&&&return
&&&&&&&&return null;
&&&&&* 根据输入的多个解释和下标返回一个值
&&&&&* @param captions
&&&&&*&&&&&&&&&&& 例如:&无,爱干净,一般,比较乱&
&&&&&* @param index
&&&&&*&&&&&&&&&&& 1
&&&&&* @return 一般
&&&&public static String getCaption(String captions, int index) {
&&&&&&&&if (index & 0 && captions != null && !captions.equals(&&)) {
&&&&&&&&&&&&String[] ss = captions.split(&,&);
&&&&&&&&&&&&if (ss != null && ss.length & 0 && index & ss.length) {
&&&&&&&&&&&&&&&&return ss[index];
&&&&&&&&&&&&}
&&&&&&&&return null;
&&&&&* 数字转字符串,如果num&=0 则输出&&;
&&&&&* @param num
&&&&&* @return
&&&&public static String numberToString(Object num) {
&&&&&&&&if (num == null) {
&&&&&&&&&&&&return null;
&&&&&&&&} else if (num instanceof Integer && (Integer) num & 0) {
&&&&&&&&&&&&return Integer.toString((Integer) num);
&&&&&&&&} else if (num instanceof Long && (Long) num & 0) {
&&&&&&&&&&&&return Long.toString((Long) num);
&&&&&&&&} else if (num instanceof Float && (Float) num & 0) {
&&&&&&&&&&&&return Float.toString((Float) num);
&&&&&&&&} else if (num instanceof Double && (Double) num & 0) {
&&&&&&&&&&&&return Double.toString((Double) num);
&&&&&&&&} else {
&&&&&&&&&&&&return &&;
&&&&&* 货币转字符串
&&&&&* @param money
&&&&&* @param style
&&&&&*&&&&&&&&&&& 样式 [default]要格式化成的格式 such as #.00, #.#
&&&&&* @return
&&&&public static String moneyToString(Object money, String style) {
&&&&&&&&if (money != null && style != null
&&&&&&&&&&&&&&&&&& (money instanceof Double || money instanceof Float)) {
&&&&&&&&&&&&Double num = (Double)
&&&&&&&&&&&&if (style.equalsIgnoreCase(&default&)) {
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&if (num == 0) {
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&return &&;
&&&&&&&&&&&&&&&&} else if ((num * 10 % 10) == 0) {
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&return Integer.toString((int) num.intValue());
&&&&&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&return num.toString();
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&DecimalFormat df = new DecimalFormat(style);
&&&&&&&&&&&&&&&&return df.format(num);
&&&&&&&&&&&&}
&&&&&&&&return null;
&&&&&* 在sou中是否存在finds 如果指定的finds字符串有一个在sou中找到,返回
&&&&&* @param sou
&&&&&* @param find
&&&&&* @return
&&&&public static boolean strPos(String sou, String... finds) {
&&&&&&&&if (sou != null && finds != null && finds.length & 0) {
&&&&&&&&&&&&for (int i = 0; i & finds. i++) {
&&&&&&&&&&&&&&&&if (sou.indexOf(finds[i]) & -1)
&&&&&&&&&&&&&&&&&&&&return true;
&&&&&&&&&&&&}
&&&&&&&&return false;
&&&&public static boolean strPos(String sou, List&String& finds) {
&&&&&&&&if (sou != null && finds != null && finds.size() & 0) {
&&&&&&&&&&&&for (String s : finds) {
&&&&&&&&&&&&&&&&if (sou.indexOf(s) & -1)
&&&&&&&&&&&&&&&&&&&&return true;
&&&&&&&&&&&&}
&&&&&&&&return false;
&&&&public static boolean strPos(String sou, String finds) {
&&&&&&&&List&String& t = splitToList(&,&, finds);
&&&&&&&&return strPos(sou, t);
&&&&&* 判断两个字符串是否相等 如果都为null则判断为相等,一个为null另一个not null则判断不相等 否则如果s1=s2则相等
&&&&&* @param s1
&&&&&* @param s2
&&&&&* @return
&&&&public static boolean equals(String s1, String s2) {
&&&&&&&&if (StringUtil.isEmpty(s1) && StringUtil.isEmpty(s2)) {
&&&&&&&&&&&&return true;
&&&&&&&&} else if (!StringUtil.isEmpty(s1) && !StringUtil.isEmpty(s2)) {
&&&&&&&&&&&&return s1.equals(s2);
&&&&&&&&return false;
&&&&public static int toInt(String s) {
&&&&&&&&if (s != null && !&&.equals(s.trim())) {
&&&&&&&&&&&&try {
&&&&&&&&&&&&&&&&return Integer.parseInt(s);
&&&&&&&&&&&&} catch (Exception e) {
&&&&&&&&&&&&&&&&return 0;
&&&&&&&&&&&&}
&&&&&&&&return 0;
&&&&public static double toDouble(String s) {
&&&&&&&&if (s != null && !&&.equals(s.trim())) {
&&&&&&&&&&&&return Double.parseDouble(s);
&&&&&&&&return 0;
&&&&public static boolean isPhone(String phone) {
&&&&&&&&if (phone == null && &&.equals(phone)) {
&&&&&&&&&&&&return false;
&&&&&&&&String[] strPhone = phone.split(&-&);
&&&&&&&&try {
&&&&&&&&&&&&for (int i = 0; i & strPhone. i++) {
&&&&&&&&&&&&&&&&Long.parseLong(strPhone[i]);
&&&&&&&&&&&&}
&&&&&&&&} catch (Exception e) {
&&&&&&&&&&&&return false;
&&&&&&&&return true;
&&&&&* 把xml 转为object
&&&&&* @param xml
&&&&&* @return
&&&&public static Object xmlToObject(String xml) {
&&&&&&&&try {
&&&&&&&&&&&&ByteArrayInputStream in = new ByteArrayInputStream(xml
&&&&&&&&&&&&&&&&&&&&.getBytes(&UTF8&));
&&&&&&&&&&&&XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(in));
&&&&&&&&&&&&return decoder.readObject();
&&&&&&&&} catch (Exception e) {
&&&&&&&&&&&&e.printStackTrace();
&&&&&&&&return null;
&&&&&* 按规定长度截断字符串,没有...的省略符号
&&&&&* @param subject
&&&&&* @param size
&&&&&* @return
&&&&public static String subStringNoEllipsis(String subject, int size) {
&&&&&&&&subject = TextUtils.htmlEncode(subject);
&&&&&&&&if (subject.length() & size) {
&&&&&&&&&&&&subject = subject.substring(0, size);
&&&&&&&&return
&&&&public static long toLong(String s) {
&&&&&&&&try {
&&&&&&&&&&&&if (s != null && !&&.equals(s.trim()))
&&&&&&&&&&&&&&&&return Long.parseLong(s);
&&&&&&&&} catch (Exception exception) {
&&&&&&&&return 0L;
&&&&public static String simpleEncrypt(String str) {
&&&&&&&&if (str != null && str.length() & 0) {
&&&&&&&&&&&&
&&&&&&&&&&&&str = str.replaceAll(&1&, &b&);
&&&&&&&&&&&&
&&&&&&&&&&&&str = str.replaceAll(&3&, &d&);
&&&&&&&&&&&&
&&&&&&&&&&&&str = str.replaceAll(&5&, &f&);
&&&&&&&&&&&&str = str.replaceAll(&6&, &g&);
&&&&&&&&&&&&str = str.replaceAll(&7&, &h&);
&&&&&&&&&&&&str = str.replaceAll(&8&, &i&);
&&&&&&&&&&&&str = str.replaceAll(&9&, &j&);
&&&&&&&&return
&&&&&* 过滤用户输入的URL地址(防治用户广告) 目前只针对以http或www开头的URL地址
&&&&&* 本方法调用的正则表达式,不建议用在对性能严格的地方例如:循环及list页面等
&&&&&* @author fengliang
&&&&&* @param str
&&&&&*&&&&&&&&&&& 需要处理的字符串
&&&&&* @return 返回处理后的字符串
&&&&public static String removeURL(String str) {
&&&&&&&&if (str != null)
&&&&&&&&&&&&str = str.toLowerCase()
&&&&&&&&&&&&&&&&&&&&.replaceAll(&(http|www|com|cn|org|\\.)+&, &&);
&&&&&&&&return
&&&&&* 随即生成指定位数的含数字验证码字符串
&&&&&* @author Peltason
&&&&&* @date
&&&&&* @param bit
&&&&&*&&&&&&&&&&& 指定生成验证码位数
&&&&&* @return String
&&&&public static String numRandom(int bit) {
&&&&&&&&if (bit == 0)
&&&&&&&&&&&&bit = 6;
&&&&&&&&String str = &&;
&&&&&&&&str = &&;
&&&&&&&&return RandomStringUtils.random(bit, str);
&&&&&* 随即生成指定位数的含验证码字符串
&&&&&* @author Peltason
&&&&&* @date
&&&&&* @param bit
&&&&&*&&&&&&&&&&& 指定生成验证码位数
&&&&&* @return String
&&&&public static String random(int bit) {
&&&&&&&&if (bit == 0)
&&&&&&&&&&&&bit = 6;
&&&&&&&&String str = &&;
&&&&&&&&str = &ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz&;
&&&&&&&&return RandomStringUtils.random(bit, str);
&&&&&* 检查字符串是否属于手机号码
&&&&&* @author Peltason
&&&&&* @date
&&&&&* @param str
&&&&&* @return boolean
&&&&public static boolean isMobile(String str) {
&&&&&&&&if (str == null || str.equals(&&))
&&&&&&&&&&&&return false;
&&&&&&&&if (str.length() != 11 || !isNumeric(str))
&&&&&&&&&&&&return false;
&&&&&&&&if (!str.substring(0, 2).equals(&13&)
&&&&&&&&&&&&&&&&&& !str.substring(0, 2).equals(&15&)
&&&&&&&&&&&&&&&&&& !str.substring(0, 2).equals(&18&))
&&&&&&&&&&&&return false;
&&&&&&&&return true;
&&&&&* Wap页面的非法字符检查
&&&&&* @author hugh115
&&&&&* @date
&&&&&* @param str
&&&&&* @return
&&&&public static String replaceWapStr(String str) {
&&&&&&&&if (str != null) {
&&&&&&&&&&&&str = str.replaceAll(&&span class=\&keyword\&&&, &&);
&&&&&&&&&&&&str = str.replaceAll(&&/span&&, &&);
&&&&&&&&&&&&str = str.replaceAll(&&strong class=\&keyword\&&&, &&);
&&&&&&&&&&&&str = str.replaceAll(&&strong&&, &&);
&&&&&&&&&&&&str = str.replaceAll(&&/strong&&, &&);
&&&&&&&&&&&&str = str.replace('$', '$');
&&&&&&&&&&&&str = str.replaceAll(&&&, &&&);
&&&&&&&&&&&&str = str.replace('&', '&');
&&&&&&&&&&&&str = str.replace('&', '<');
&&&&&&&&&&&&str = str.replace('&', '>');
&&&&&&&&return
&&&&&* 字符串转float 如果异常返回0.00
&&&&&* @param s
&&&&&*&&&&&&&&&&& 输入的字符串
&&&&&* @return 转换后的float
&&&&public static Float toFloat(String s) {
&&&&&&&&try {
&&&&&&&&&&&&return Float.parseFloat(s);
&&&&&&&&} catch (NumberFormatException e) {
&&&&&&&&&&&&return new Float(0);
&&&&&* 页面中去除字符串中的空格、回车、换行符、制表符
&&&&&* @author shazao
&&&&&* @date
&&&&&* @param str
&&&&&* @return
&&&&public static String replaceBlank(String str) {
&&&&&&&&if (str != null) {
&&&&&&&&&&&&Pattern p = pile(&\\s*|\t|\r|\n&);
&&&&&&&&&&&&Matcher m = p.matcher(str);
&&&&&&&&&&&&str = m.replaceAll(&&);
&&&&&&&&return
&&&&&* 全角生成半角
&&&&&* @author bailong
&&&&&* @date
&&&&&* @param str
&&&&&* @return
&&&&public static String Q2B(String QJstr) {
&&&&&&&&String outStr = &&;
&&&&&&&&String Tstr = &&;
&&&&&&&&byte[] b = null;
&&&&&&&&for (int i = 0; i & QJstr.length(); i++) {
&&&&&&&&&&&&try {
&&&&&&&&&&&&&&&&Tstr = QJstr.substring(i, i + 1);
&&&&&&&&&&&&&&&&b = Tstr.getBytes(&unicode&);
&&&&&&&&&&&&} catch (java.io.UnsupportedEncodingException e) {
&&&&&&&&&&&&&&&&if (logger.isErrorEnabled()) {
&&&&&&&&&&&&&&&&&&&&logger.error(e);
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&}
&&&&&&&&&&&&if (b[3] == -1) {
&&&&&&&&&&&&&&&&b[2] = (byte) (b[2] + 32);
&&&&&&&&&&&&&&&&b[3] = 0;
&&&&&&&&&&&&&&&&try {
&&&&&&&&&&&&&&&&&&&&outStr = outStr + new String(b, &unicode&);
&&&&&&&&&&&&&&&&} catch (java.io.UnsupportedEncodingException ex) {
&&&&&&&&&&&&&&&&&&&&if (logger.isErrorEnabled()) {
&&&&&&&&&&&&&&&&&&&&&&&&logger.error(ex);
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&outStr = outStr + T
&&&&&&&&&&&&}
&&&&&&&&return outS
&&&&&* 转换编码
&&&&&* @param s
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @param fencode
&&&&&*&&&&&&&&&&& 源编码格式
&&&&&* @param bencode
&&&&&*&&&&&&&&&&& 目标编码格式
&&&&&* @return 目标编码
&&&&public static String changCoding(String s, String fencode, String bencode) {
&&&&&&&&try {
&&&&&&&&&&&&String str = new String(s.getBytes(fencode), bencode);
&&&&&&&&&&&&return
&&&&&&&&} catch (UnsupportedEncodingException e) {
&&&&&&&&&&&&return s;
&&&&&* *************************************************************************
&&&&&* 修改:刘黎明 修改时间:
&&&&&* @param str
&&&&&* @return
&&&&&*************************************************************************
&&&&public static String removeHTMLLableExe(String str) {
&&&&&&&&str = stringReplace(str, &&\\s*&&, &&&&);
&&&&&&&&str = stringReplace(str, &&&, & &);
&&&&&&&&str = stringReplace(str, &&br ?/?&&, &\n&);
&&&&&&&&str = stringReplace(str, &&([^&&]+)&&, &&);
&&&&&&&&str = stringReplace(str, &\\s\\s\\s*&, & &);
&&&&&&&&str = stringReplace(str, &^\\s*&, &&);
&&&&&&&&str = stringReplace(str, &\\s*$&, &&);
&&&&&&&&str = stringReplace(str, & +&, & &);
&&&&&&&&return
&&&&&* 除去html标签
&&&&&* @param str
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @return 目标字符串
&&&&public static String removeHTMLLable(String str) {
&&&&&&&&str = stringReplace(str, &\\s&, &&);
&&&&&&&&str = stringReplace(str, &&br ?/?&&, &\n&);
&&&&&&&&str = stringReplace(str, &&([^&&]+)&&, &&);
&&&&&&&&str = stringReplace(str, &&&, & &);
&&&&&&&&str = stringReplace(str, &&(\\S)(\\S?)(\\S?)(\\S?);&, &&);
&&&&&&&&return
&&&&&* 去掉HTML标签之外的字符串
&&&&&* @param str
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @return 目标字符串
&&&&public static String removeOutHTMLLable(String str) {
&&&&&&&&str = stringReplace(str, &&([^&&]+)&&, &&&&);
&&&&&&&&str = stringReplace(str, &^([^&&]+)&&, &&&);
&&&&&&&&str = stringReplace(str, &&([^&&]+)$&, &&&);
&&&&&&&&return
&&&&&* 字符串替换
&&&&&* @param str
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @param sr
&&&&&*&&&&&&&&&&& 正则表达式样式
&&&&&* @param sd
&&&&&*&&&&&&&&&&& 替换文本
&&&&&* @return 结果串
&&&&public static String stringReplace(String str, String sr, String sd) {
&&&&&&&&String regEx =
&&&&&&&&Pattern p = pile(regEx, Pattern.CASE_INSENSITIVE);
&&&&&&&&Matcher m = p.matcher(str);
&&&&&&&&str = m.replaceAll(sd);
&&&&&&&&return
&&&&&* 将html的省略写法替换成非省略写法
&&&&&* @param str
&&&&&*&&&&&&&&&&& html字符串
&&&&&* @param pt
&&&&&*&&&&&&&&&&& 标签如table
&&&&&* @return 结果串
&&&&public static String fomateToFullForm(String str, String pt) {
&&&&&&&&String regEx = &&& + pt + &\\s+([\\S&&[^&&]]*)/&&;
&&&&&&&&Pattern p = pile(regEx, Pattern.CASE_INSENSITIVE);
&&&&&&&&Matcher m = p.matcher(str);
&&&&&&&&String[] sa = null;
&&&&&&&&String sf = &&;
&&&&&&&&String sf2 = &&;
&&&&&&&&String sf3 = &&;
&&&&&&&&for (; m.find();) {
&&&&&&&&&&&&sa = p.split(str);
&&&&&&&&&&&&if (sa == null) {
&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&}
&&&&&&&&&&&&sf = str.substring(sa[0].length(), str
&&&&&&&&&&&&&&&&&&&&.indexOf(&/&&, sa[0].length()));
&&&&&&&&&&&&sf2 = sf + &&&/& + pt + &&&;
&&&&&&&&&&&&sf3 = str.substring(sa[0].length() + sf.length() + 2);
&&&&&&&&&&&&str = sa[0] + sf2 + sf3;
&&&&&&&&&&&&sa = null;
&&&&&&&&return
&&&&&* 得到字符串的子串位置序列
&&&&&* @param str
&&&&&*&&&&&&&&&&& 字符串
&&&&&* @param sub
&&&&&*&&&&&&&&&&& 子串
&&&&&* @param b
&&&&&*&&&&&&&&&&& true子串前端,false子串后端
&&&&&* @return 字符串的子串位置序列
&&&&public static int[] getSubStringPos(String str, String sub, boolean b) {
&&&&&&&&String[] sp = null;
&&&&&&&&int l = sub.length();
&&&&&&&&sp = splitString(str, sub);
&&&&&&&&if (sp == null) {
&&&&&&&&&&&&return null;
&&&&&&&&int[] ip = new int[sp.length - 1];
&&&&&&&&for (int i = 0; i & sp.length - 1; i++) {
&&&&&&&&&&&&ip[i] = sp[i].length() +
&&&&&&&&&&&&if (i != 0) {
&&&&&&&&&&&&&&&&ip[i] += ip[i - 1];
&&&&&&&&&&&&}
&&&&&&&&if (b) {
&&&&&&&&&&&&for (int j = 0; j & ip. j++) {
&&&&&&&&&&&&&&&&ip[j] = ip[j] -
&&&&&&&&&&&&}
&&&&&&&&return
&&&&&* 根据正则表达式分割字符串
&&&&&* @param str
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @param ms
&&&&&*&&&&&&&&&&& 正则表达式
&&&&&* @return 目标字符串组
&&&&public static String[] splitString(String str, String ms) {
&&&&&&&&String regEx =
&&&&&&&&Pattern p = pile(regEx, Pattern.CASE_INSENSITIVE);
&&&&&&&&String[] sp = p.split(str);
&&&&&&&&return
&&&&&* *************************************************************************
&&&&&* 根据正则表达式提取字符串,相同的字符串只返回一个
&&&&&* @author 刘黎明
&&&&&* @param str
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @param pattern
&&&&&*&&&&&&&&&&& 正则表达式
&&&&&* @return 目标字符串数据组
&&&&&*************************************************************************
&&&&public static String[] getStringArrayByPattern(String str, String pattern) {
&&&&&&&&Pattern p = pile(pattern, Pattern.CASE_INSENSITIVE);
&&&&&&&&Matcher matcher = p.matcher(str);
&&&&&&&&Set&String& result = new HashSet&String&();
&&&&&&&&while (matcher.find()) {
&&&&&&&&&&&&for (int i = 0; i & matcher.groupCount(); i++) {
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&result.add(matcher.group(i));
&&&&&&&&&&&&}
&&&&&&&&String[] resultStr = null;
&&&&&&&&if (result.size() & 0) {
&&&&&&&&&&&&resultStr = new String[result.size()];
&&&&&&&&&&&&return result.toArray(resultStr);
&&&&&&&&return resultS
&&&&&* 得到第一个b,e之间的字符串,并返回e后的子串
&&&&&* @param s
&&&&&*&&&&&&&&&&& 源字符串
&&&&&* @param b
&&&&&*&&&&&&&&&&& 标志开始
&&&&&* @param e
&&&&&*&&&&&&&&&&& 标志结束
&&&&&* @return b,e之间的字符串
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&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&&&&&
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&public static String getHtmlSubString(String str, int len, String tail) {
&&&&&&&&if (str == null || str.length() &= len) {
&&&&&&&&&&&&return
&&&&&&&&int length = str.length();
&&&&&&&&char c = ' ';
&&&&&&&&String tag = null;
&&&&&&&&String name = null;
&&&&&&&&int size = 0;
&&&&&&&&String result = &&;
&&&&&&&&boolean isTag = false;
&&&&&&&&List&String& tags = new ArrayList&String&();
&&&&&&&&int i = 0;
&&&&&&&&for (int end = 0, spanEnd = 0; i & length && len & 0; i++) {
&&&&&&&&&&&&c = str.charAt(i);
&&&&&&&&&&&&if (c == '&') {
&&&&&&&&&&&&&&&&end = str.indexOf('&', i);
&&&&&&&&&&&&}
&&&&&&&&&&&&if (end & 0) {
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&tag = str.substring(i, end + 1);
&&&&&&&&&&&&&&&&int n = tag.length();
&&&&&&&&&&&&&&&&if (tag.endsWith(&/&&)) {
&&&&&&&&&&&&&&&&&&&&isTag = true;
&&&&&&&&&&&&&&&&} else if (tag.startsWith(&&/&)) {
&&&&&&&&&&&&&&&&&&&&name = tag.substring(2, end - i);
&&&&&&&&&&&&&&&&&&&&size = tags.size() - 1;
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&if (size &= 0 && name.equals(tags.get(size))) {
&&&&&&&&&&&&&&&&&&&&&&&&isTag = true;
&&&&&&&&&&&&&&&&&&&&&&&&tags.remove(size);
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&&&&&spanEnd = tag.indexOf(' ', 0);
&&&&&&&&&&&&&&&&&&&&spanEnd = spanEnd & 0 ? spanEnd :
&&&&&&&&&&&&&&&&&&&&name = tag.substring(1, spanEnd);
&&&&&&&&&&&&&&&&&&&&if (name.trim().length() & 0) {
&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&spanEnd = str.indexOf(&&/& + name + &&&, end);
&&&&&&&&&&&&&&&&&&&&&&&&if (spanEnd & 0) {
&&&&&&&&&&&&&&&&&&&&&&&&&&&&isTag = true;
&&&&&&&&&&&&&&&&&&&&&&&&&&&&tags.add(name);
&&&&&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&if (!isTag) {
&&&&&&&&&&&&&&&&&&&&if (n &= len) {
&&&&&&&&&&&&&&&&&&&&&&&&result += tag.substring(0, len);
&&&&&&&&&&&&&&&&&&&&&&&&break;
&&&&&&&&&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&&&&&&&&&len -=
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&result +=
&&&&&&&&&&&&&&&&isTag = false;
&&&&&&&&&&&&&&&&i =
&&&&&&&&&&&&&&&&end = 0;
&&&&&&&&&&&&} else {
&&&&&&&&&&&&&&&&len--;
&&&&&&&&&&&&&&&&result +=
&&&&&&&&&&&&}
&&&&&&&&for (String endTag : tags) {
&&&&&&&&&&&&result += &&/& + endTag + &&&;
&&&&&&&&if (i & length) {
&&&&&&&&&&&&result +=
&&&&&&&&return
文章:344 篇
评论:921 条
访问:2545102 次
本站基于 Loachs 技术构建}

我要回帖

更多关于 json封装list 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信