`
qq1988627
  • 浏览: 107332 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

字符处理工具类

 
阅读更多
package j2ee.util;

import j2ee.tag.instance.TextBoxInt;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;
@SuppressWarnings("unchecked")
public class StringUtil {
	public StringUtil() {
	}

	public static String trimToEmpty(String str) {
		return str == null ? "" : str.trim();
	}

	public static boolean isEmpty(String str) {
		return str == null || str.trim().length() == 0;
	}

	public static String notNull(String theString) {
		if (theString == null)
			return new String("");
		else
			return theString.trim();
	}

	public static String notNull(Object theString) {
		String str = (String) theString;
		return notNull(str);
	}

	public static String notNull(String name, Properties prop) {
		name = notNull(name);
		String str = notNull(prop.getProperty(name));
		return str;
	}

	public static String numberToLetter(int number, boolean upperCaseFlag)
			throws Exception {
		if (number < 1 || number > 26)
			throw new Exception(
					"The number is out of the proper range (1 to 26) to be converted to a letter.");
		int modnumber = number + 9;
		char thechar = Character.forDigit(modnumber, 36);
		if (upperCaseFlag)
			thechar = Character.toUpperCase(thechar);
		return (new StringBuilder()).append(thechar).toString();
	}

	
	public static Vector explode(String str, String tok) {
		StringTokenizer tokens = new StringTokenizer(str, tok);
		Vector v = new Vector();
		if (tokens.countTokens() > 1)
			while (tokens.hasMoreTokens()) {
				String s = tokens.nextToken().trim();
				if (!s.equals(""))
					v.add(s);
			}
		else
			v.add(str);
		return v;
	}

	public static String implode(String bind, Vector v) {
		String str = "";
		String oneStr = "";
		boolean needBind = false;
		for (Enumeration e = v.elements(); e.hasMoreElements();) {
			oneStr = (String) e.nextElement();
			str = (new StringBuilder(String.valueOf(str))).append(
					needBind ? bind : "").toString();
			str = (new StringBuilder(String.valueOf(str))).append(oneStr)
					.toString();
			needBind = true;
		}

		return str;
	}

	public static String implode(String bind, String str_array[]) {
		String str = "";
		String oneStr = "";
		boolean needBind = false;
		for (int i = 0; i < str_array.length; i++) {
			oneStr = str_array[i];
			str = (new StringBuilder(String.valueOf(str))).append(
					needBind ? bind : "").toString();
			str = (new StringBuilder(String.valueOf(str))).append(oneStr)
					.toString();
			needBind = true;
		}

		return str;
	}

	public static Vector toVector(String str_array[]) {
		Vector v = new Vector();
		for (int i = 0; i < str_array.length; i++)
			v.add(str_array[i]);

		return v;
	}

	public static String cutByMaxLength(String str, int max_num, String lan) {
		if (str.length() > max_num)
			try {
				str = str.substring(0, max_num);
				if (lan.equals("en")) {
					str = str.substring(0, str.lastIndexOf(" "));
					str = (new StringBuilder(String.valueOf(str))).append(
							" ...").toString();
				} else {
					int j;
					for (j = 0; j < max_num; j++) {
						byte word[] = str.substring(j, j + 1).getBytes();
						int tempInt = word[0] & 255;
						if (tempInt > 128)
							j++;
					}

					if (j != max_num)
						str = str.substring(0, max_num - 1);
					str = (new StringBuilder(String.valueOf(str)))
							.append("...").toString();
				}
			} catch (Exception e) {
				return str;
			}
		return str;
	}

	public static int getHzLen(String str) {
		int hzLen = 0;
		if (str != null && str.length() > 0)
			hzLen = str.getBytes().length;
		return hzLen;
	}

	public static String getFormStr(String name, Properties prop, String cmp,
			String selected_str) {
		return getFormStr(notNull(name, prop), cmp, selected_str);
	}

	public static String getFormStr(String value, String cmp,
			String selected_str) {
		if (value.equals(cmp))
			return selected_str;
		else
			return "";
	}

	public static Properties setEmptyValue(String name, Properties prop,
			String value) {
		if (notNull(name, prop).equals(""))
			prop.setProperty(name, notNull(value));
		return prop;
	}

	public static String codeConvert(String str) {
		if (str == null)
			return "";
		if (str.length() == 0)
			return "";
		else
			return str;
	}

	public static String codeEncode(String str) {
		if (str == null)
			return "";
		str = str.trim();
		if (str.length() == 0)
			return "";
		else
			return str;
	}

	public static String webCodeConvert(String str, String language) {
		if (str == null)
			return "";
		str = str.trim();
		if (str.length() == 0)
			return "";
		if (language == null)
			language = "";
		language = language.trim();
		if (language.toLowerCase().equals("cn"))
			language = "GBK";
		else if (language.toLowerCase().equals("jp"))
			language = "SJIS";
		else
			language = "";
		try {
			str = new String(str.getBytes(language), "8859_1");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return str;
	}

	public static String isoToGBConvert(String str) {
		if (str == null)
			return "";
		str = str.trim();
		if (str.length() == 0)
			return "";
		try {
			str = new String(str.getBytes("8859_1"), "gb2312");
		} catch (UnsupportedEncodingException unsupportedencodingexception) {
		}
		return str;
	}

	public static String notBlankNull(String theString) {
		if (theString == null)
			return "null";
		if (theString.trim().equals(""))
			return "''";
		else
			return (new StringBuilder("'")).append(theString.trim())
					.append("'").toString();
	}

	public static boolean hasCJK(String str) {
		boolean flag = false;
		if (str != null)
			flag = str.getBytes().length != str.length();
		return flag;
	}

	public static boolean isInteger(String str, int len) {
		if ("".equals(str))
			str = "0";
		if (len > 0 && str.length() != len)
			return false;
		try {
			Integer.parseInt(str);
		} catch (Exception exception) {
			return false;
		}
		return true;
	}

	public static boolean isEqual(char one[], char other[]) {
		boolean retVal = false;
		if (one != null && other != null && one.length == other.length) {
			for (int i = 0; i < one.length; i++) {
				if (one[i] != other[i])
					break;
				if (i == one.length - 1)
					retVal = true;
			}

		}
		return retVal;
	}

	public static boolean isDoubleValid(String str, int intLen) {
		if ("".equals(str))
			str = "0";
		Double.parseDouble(str);
		int pointPos = str.indexOf(".");
		if (pointPos == -1)
			return str.length() <= intLen;
		if (pointPos == 0)
			return true;
		return pointPos <= intLen;
	}

	public static int compareUtil(String s1, String s2) {
		int len = s1.length() - s2.length();
		if (len > 0) {
			for (int i = 0; i < len; i++)
				s2 = (new StringBuilder("0")).append(s2).toString();

		}
		if (len < 0) {
			len = -len;
			for (int i = 0; i < len; i++)
				s1 = (new StringBuilder("0")).append(s1).toString();

		}
		int result = s1.compareTo(s2);
		return result;
	}


	public static String collectionToDelimitedString(Collection c, String delim) {
		if (c == null)
			return "null";
		else
			return iteratorToDelimitedString(c.iterator(), delim);
	}

	public static String iteratorToDelimitedString(Iterator itr, String delim) {
		if (itr == null)
			return "null";
		StringBuffer sb = new StringBuffer();
		int i = 0;
		for (; itr.hasNext(); sb.append(itr.next()))
			if (i++ > 0)
				sb.append(delim);

		return sb.toString();
	}

	public static String arrayToDelimitedString(Object arr[], String delim) {
		return arrayToDelimitedString(arr, delim, "");
	}

	public static boolean isDigitOk(int num) {
		return num <= 0;
	}

	public static String arrayToDelimitedString(Object arr[], String delim,
			String quoteMark) {
		if (arr == null)
			return "null";
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < arr.length; i++) {
			if (i > 0)
				sb.append(delim);
			sb.append(quote(arr[i].toString(), quoteMark));
		}

		return sb.toString();
	}

	public static String quote(String str, String quoteMark) {
		return (new StringBuilder(String.valueOf(quoteMark))).append(str)
				.append(quoteMark).toString();
	}

	public static String[] commaDelimitedListToStringArray(String s) {
		return delimitedListToStringArray(s, ",");
	}

	public static String[] delimitedListToStringArray(String s, String delimiter) {
		if (s == null)
			return new String[0];
		if (delimiter == null)
			return (new String[] { s });
		List l = new LinkedList();
		int pos = 0;
		for (int delpos = 0; (delpos = s.indexOf(delimiter, pos)) != -1;) {
			l.add(s.substring(pos, delpos));
			pos = delpos + delimiter.length();
		}

		if (pos <= s.length())
			l.add(s.substring(pos));
		return (String[]) l.toArray(new String[l.size()]);
	}

	public static String getFileName(String path) {
		return getFileName(path, File.pathSeparator);
	}

	public static String getFileName(String path, String pathSeparator) {
		if (path == null)
			return null;
		int position = path.lastIndexOf(pathSeparator);
		if (position >= 0)
			return path.substring(position + 1);
		else
			return path;
	}

	public static String getMd5(String s) {
		char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
				'A', 'B', 'C', 'D', 'E', 'F' };
		try {
			byte strTemp[] = s.getBytes();
			MessageDigest mdTemp = MessageDigest.getInstance("MD5");
			mdTemp.update(strTemp);
			byte md[] = mdTemp.digest();
			int j = md.length;
			char str[] = new char[j * 2];
			int k = 0;
			for (int i = 0; i < j; i++) {
				byte byte0 = md[i];
				str[k++] = hexDigits[byte0 >>> 4 & 15];
				str[k++] = hexDigits[byte0 & 15];
			}

			return new String(str);
		} catch (Exception e) {
			return null;
		}
	}
	
	public static String toCommaSeparatorString(Object[] values){
		StringBuffer buffer = new StringBuffer();
		for(int i=0;i<values.length;i++){
			buffer.append(values[i])
				  .append(i==values.length-1?"":",");
		}
		return buffer.toString();
	}

}


package com.atom.util;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;

import BizServer.BizKernel.FilterCollection;

import com.atom.proxyModex.SupportAccess;
@SuppressWarnings("unchecked")
public class StringUtil {
	public StringUtil() {
	}

	public static String trimToEmpty(String str) {
		return str == null ? "" : str.trim();
	}
	
	//pxw
	public static boolean isTrimEmpty(String s){
		return s==null || s.trim().equals("");
	}
	
	//pxw
	public static String toSafeText(String s){
		return s==null?"":s;
	}
	
	//pxw
	public static boolean isEmpty(String str) {
		return str == null || str.length() == 0;
	}
	//pxw
	public static final String SplitString = "[]";
	public static String[] SplitTableAndText(String s){
			List<String> resultList = new ArrayList<String>();
			while(true){
				int begin = s.indexOf("[");
				int end = s.indexOf("]");
				if(begin<0 || end<0) break;
				String singleData = s.substring(begin+1, end);
				if(!StringUtil.isTrimEmpty(singleData))
					resultList.add(singleData);
				s=s.substring(end+1);
			}
			
			return resultList.toArray(new String[resultList.size()]);
	}

	public static String notNull(String theString) {
		if (theString == null)
			return new String("");
		else
			return theString.trim();
	}

	public static String notNull(Object theString) {
		String str = (String) theString;
		return notNull(str);
	}

	public static String notNull(String name, Properties prop) {
		name = notNull(name);
		String str = notNull(prop.getProperty(name));
		return str;
	}

	public static String numberToLetter(int number, boolean upperCaseFlag)
			throws Exception {
		if (number < 1 || number > 26)
			throw new Exception(
					"The number is out of the proper range (1 to 26) to be converted to a letter.");
		int modnumber = number + 9;
		char thechar = Character.forDigit(modnumber, 36);
		if (upperCaseFlag)
			thechar = Character.toUpperCase(thechar);
		return (new StringBuilder()).append(thechar).toString();
	}

	
	public static Vector explode(String str, String tok) {
		StringTokenizer tokens = new StringTokenizer(str, tok);
		Vector v = new Vector();
		if (tokens.countTokens() > 1)
			while (tokens.hasMoreTokens()) {
				String s = tokens.nextToken().trim();
				if (!s.equals(""))
					v.add(s);
			}
		else
			v.add(str);
		return v;
	}

	public static String implode(String bind, Vector v) {
		String str = "";
		String oneStr = "";
		boolean needBind = false;
		for (Enumeration e = v.elements(); e.hasMoreElements();) {
			oneStr = (String) e.nextElement();
			str = (new StringBuilder(String.valueOf(str))).append(
					needBind ? bind : "").toString();
			str = (new StringBuilder(String.valueOf(str))).append(oneStr)
					.toString();
			needBind = true;
		}

		return str;
	}

	public static String implode(String bind, String str_array[]) {
		String str = "";
		String oneStr = "";
		boolean needBind = false;
		for (int i = 0; i < str_array.length; i++) {
			oneStr = str_array[i];
			str = (new StringBuilder(String.valueOf(str))).append(
					needBind ? bind : "").toString();
			str = (new StringBuilder(String.valueOf(str))).append(oneStr)
					.toString();
			needBind = true;
		}

		return str;
	}

	public static Vector toVector(String str_array[]) {
		Vector v = new Vector();
		for (int i = 0; i < str_array.length; i++)
			v.add(str_array[i]);

		return v;
	}

	public static String cutByMaxLength(String str, int max_num, String lan) {
		if (str.length() > max_num)
			try {
				str = str.substring(0, max_num);
				if (lan.equals("en")) {
					str = str.substring(0, str.lastIndexOf(" "));
					str = (new StringBuilder(String.valueOf(str))).append(
							" ...").toString();
				} else {
					int j;
					for (j = 0; j < max_num; j++) {
						byte word[] = str.substring(j, j + 1).getBytes();
						int tempInt = word[0] & 255;
						if (tempInt > 128)
							j++;
					}

					if (j != max_num)
						str = str.substring(0, max_num - 1);
					str = (new StringBuilder(String.valueOf(str)))
							.append("...").toString();
				}
			} catch (Exception e) {
				return str;
			}
		return str;
	}

	public static int getHzLen(String str) {
		int hzLen = 0;
		if (str != null && str.length() > 0)
			hzLen = str.getBytes().length;
		return hzLen;
	}

	public static String getFormStr(String name, Properties prop, String cmp,
			String selected_str) {
		return getFormStr(notNull(name, prop), cmp, selected_str);
	}

	public static String getFormStr(String value, String cmp,
			String selected_str) {
		if (value.equals(cmp))
			return selected_str;
		else
			return "";
	}

	public static Properties setEmptyValue(String name, Properties prop,
			String value) {
		if (notNull(name, prop).equals(""))
			prop.setProperty(name, notNull(value));
		return prop;
	}

	public static String codeConvert(String str) {
		if (str == null)
			return "";
		if (str.length() == 0)
			return "";
		else
			return str;
	}

	public static String codeEncode(String str) {
		if (str == null)
			return "";
		str = str.trim();
		if (str.length() == 0)
			return "";
		else
			return str;
	}

	public static String webCodeConvert(String str, String language) {
		if (str == null)
			return "";
		str = str.trim();
		if (str.length() == 0)
			return "";
		if (language == null)
			language = "";
		language = language.trim();
		if (language.toLowerCase().equals("cn"))
			language = "GBK";
		else if (language.toLowerCase().equals("jp"))
			language = "SJIS";
		else
			language = "";
		try {
			str = new String(str.getBytes(language), "8859_1");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return str;
	}

	public static String isoToGBConvert(String str) {
		if (str == null)
			return "";
		str = str.trim();
		if (str.length() == 0)
			return "";
		try {
			str = new String(str.getBytes("8859_1"), "gb2312");
		} catch (UnsupportedEncodingException unsupportedencodingexception) {
		}
		return str;
	}

	public static String notBlankNull(String theString) {
		if (theString == null)
			return "null";
		if (theString.trim().equals(""))
			return "''";
		else
			return (new StringBuilder("'")).append(theString.trim())
					.append("'").toString();
	}

	public static boolean hasCJK(String str) {
		boolean flag = false;
		if (str != null)
			flag = str.getBytes().length != str.length();
		return flag;
	}

	public static boolean isInteger(String str, int len) {
		if ("".equals(str))
			str = "0";
		if (len > 0 && str.length() != len)
			return false;
		try {
			Integer.parseInt(str);
		} catch (Exception exception) {
			return false;
		}
		return true;
	}

	public static boolean isEqual(char one[], char other[]) {
		boolean retVal = false;
		if (one != null && other != null && one.length == other.length) {
			for (int i = 0; i < one.length; i++) {
				if (one[i] != other[i])
					break;
				if (i == one.length - 1)
					retVal = true;
			}

		}
		return retVal;
	}

	public static boolean isDoubleValid(String str, int intLen) {
		if ("".equals(str))
			str = "0";
		Double.parseDouble(str);
		int pointPos = str.indexOf(".");
		if (pointPos == -1)
			return str.length() <= intLen;
		if (pointPos == 0)
			return true;
		return pointPos <= intLen;
	}

	public static int compareUtil(String s1, String s2) {
		int len = s1.length() - s2.length();
		if (len > 0) {
			for (int i = 0; i < len; i++)
				s2 = (new StringBuilder("0")).append(s2).toString();

		}
		if (len < 0) {
			len = -len;
			for (int i = 0; i < len; i++)
				s1 = (new StringBuilder("0")).append(s1).toString();

		}
		int result = s1.compareTo(s2);
		return result;
	}


	public static String collectionToDelimitedString(Collection c, String delim) {
		if (c == null)
			return "null";
		else
			return iteratorToDelimitedString(c.iterator(), delim);
	}

	public static String iteratorToDelimitedString(Iterator itr, String delim) {
		if (itr == null)
			return "null";
		StringBuffer sb = new StringBuffer();
		int i = 0;
		for (; itr.hasNext(); sb.append(itr.next()))
			if (i++ > 0)
				sb.append(delim);

		return sb.toString();
	}

	public static String arrayToDelimitedString(Object arr[], String delim) {
		return arrayToDelimitedString(arr, delim, "");
	}

	public static boolean isDigitOk(int num) {
		return num <= 0;
	}

	public static String arrayToDelimitedString(Object arr[], String delim,
			String quoteMark) {
		if (arr == null)
			return "null";
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < arr.length; i++) {
			if (i > 0)
				sb.append(delim);
			sb.append(quote(arr[i].toString(), quoteMark));
		}

		return sb.toString();
	}

	public static String quote(String str, String quoteMark) {
		return (new StringBuilder(String.valueOf(quoteMark))).append(str)
				.append(quoteMark).toString();
	}

	public static String[] commaDelimitedListToStringArray(String s) {
		return delimitedListToStringArray(s, ",");
	}

	public static String[] delimitedListToStringArray(String s, String delimiter) {
		if (s == null)
			return new String[0];
		if (delimiter == null)
			return (new String[] { s });
		List l = new LinkedList();
		int pos = 0;
		for (int delpos = 0; (delpos = s.indexOf(delimiter, pos)) != -1;) {
			l.add(s.substring(pos, delpos));
			pos = delpos + delimiter.length();
		}

		if (pos <= s.length())
			l.add(s.substring(pos));
		return (String[]) l.toArray(new String[l.size()]);
	}

	public static String getFileName(String path) {
		return getFileName(path, File.pathSeparator);
	}

	public static String getFileName(String path, String pathSeparator) {
		if (path == null)
			return null;
		int position = path.lastIndexOf(pathSeparator);
		if (position >= 0)
			return path.substring(position + 1);
		else
			return path;
	}

	public static String getMd5(String s) {
		char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
				'A', 'B', 'C', 'D', 'E', 'F' };
		try {
			byte strTemp[] = s.getBytes();
			MessageDigest mdTemp = MessageDigest.getInstance("MD5");
			mdTemp.update(strTemp);
			byte md[] = mdTemp.digest();
			int j = md.length;
			char str[] = new char[j * 2];
			int k = 0;
			for (int i = 0; i < j; i++) {
				byte byte0 = md[i];
				str[k++] = hexDigits[byte0 >>> 4 & 15];
				str[k++] = hexDigits[byte0 & 15];
			}

			return new String(str);
		} catch (Exception e) {
			return null;
		}
	}
	
	//pxw
	public static String Format(String patternStr,String... s){
		for(int i=0;i<s.length;i++){
			patternStr = patternStr.replace("{"+i+"}", s[i]);
		}
		return patternStr;
	}
	
	public static int[] toIntegerArray(String[] s){
		int[] toInt=new int[s.length];
		for(int i=0;i<s.length;i++){
			toInt[i]=Integer.valueOf(s[i]);
		}
		return toInt;
	}	
	
	public static String trimForChar(String s,char split){
		s = trimToEmpty(s);
		if(isEmpty(s)) return s;
		char[] chars = s.toCharArray();
		int begin = 0;
		int end = 0;
		boolean content = false;
		for(int i=0;i<chars.length;i++){
			if(chars[i]==split){
				if(!content){
					begin = i+1;
				}
			}else{
				content = true;
				end = i+1;
			}
		}
		if(end==0){
			return "";
		}
		s = s.substring(begin,end);
		return s;
	}
	
	public static void main(String[] args) throws Exception {
//		String ids = ",,,,";
//		System.out.println(trimForChar(ids, ','));
//		String rep = "aaa{1}bbb{0}";
//		System.out.println(Format(rep, "bb","aa"));
		String ids = "aaa,aaa,,,";
		System.out.println(ids.split(",").length);
	}

	public static int[] toIntegerArray(String ids) { 
		if(ids==null){
			return null;
		}
		if(ids.endsWith(",")){
			ids=ids.substring(0, ids.length()-1);
		}
		String[] id=ids.split(",");
		return toIntegerArray(id);
	}	
	
	public static String trimFirstAndLast (String s,String split) {
		s = trimToEmpty(s);
		if(isEmpty(s)) return s;
		if(s.endsWith(split)){
			s=s.substring(0, s.length()-1);
		}
		if(s.substring(0, 1).equalsIgnoreCase(split)){
		s=s.substring(1);
		}
		return s;
	}	
	
	/**
	 * String转Date
	 * @param date 日期时间
	 * @param dateFormat 日期格式
	 * @return date
	 * @author sean
	 */
	public static Date str2date(String date,String dateFormat){
		try {
			DateFormat format = new SimpleDateFormat(dateFormat);//yyyy-MM-dd HH:mm:ss
		    Date redate = format.parse(date);  // Thu Jan 18 00:00:00 CST 2007
		    return redate;
		} catch (Exception e) {    
		    e.printStackTrace();    
		}  
		return null;
	}
	
	/**
	 * string转list
	 * @param str
	 * @return list
	 */
	public static List str2list(String str){
		if(str==null || str==""){
			return null;
		}
		if(str.endsWith(",")){
			str=str.substring(0, str.length()-1);
		}
		ArrayList list = new ArrayList();
		String[] id=str.split(",");
		for(int i=0;i<id.length;i++){
			list.add(id[i]);
		}
		return list;
	}
}
分享到:
评论

相关推荐

    StringUtil(通过的字符处理工具类)

    `StringUtil`是一个常见的Java工具类,它包含了大量用于处理字符串的方法,可以极大地简化字符串操作,提高代码的可读性和效率。在Java开发中,我们经常会遇到对字符串进行各种操作的需求,如检查空值、分割、连接、...

    字符转换工具类

    在IT行业中,字符转换工具类是编程中常见的一种实用工具,尤其在处理字符串与各种编码格式之间转换时显得尤为重要。这个“字符转换工具类”似乎是一个专门为生成HTML源码而设计的工具,它包含了全面的源码实现,并且...

    工具类_字符串处理

    下面我们将深入探讨这个主题,了解一些常见的字符串处理工具类和相关知识点。 首先,我们来看一下“源码”这个标签。源码分析是理解工具类内部工作原理的关键,通过阅读和研究源码,我们可以学习到如何设计和实现...

    java字符串基本处理工具类

    java字符串处理的util工具类,也可以同时添加一些其他字符处理的方法,对于项目中特殊字符处理,完成项目中基本的字串符处理。

    自己整理的StringUtil ,字符串处理工具类.txt

    自己整理的StringUtil ,字符串处理工具类,很全面的方法,对象之间的数据转换

    排列字符串工具类

    标题所提到的“排列字符串工具类”是一个专门为处理字符串排序而设计的类,它能够有效地对字符数组进行排序,使得数字、拼音、汉字以及其它非这三类字符按照特定的顺序排列。 首先,我们来看排序的基本概念。在...

    Str字符串处理工具类

    1.字符串转换为其他类型 2.字符串首字母转换为大写 3.取得一个随机字符串,包含数字和字符 4.转码 5.替换特殊字符串 6.公式格式化

    java自定义工具类,对字符串进行特殊处理

    1.删除字符 2.去空格 3.去除所有空格和特殊字符 4.判断邮箱 5.字符串集合转字符串 6.只保留汉字 7.关键词前后是否包含英文字母 8.去除字符串中的附件 9.获取下标单个位置和所有位置

    安卓开发框架工具类相关-很实用的安卓开发工具类开发必备日期处理工具类IO流转换工具类打印日志工具类屏幕字符串工具类Toast工具类弹框工具类.zip

    很实用的安卓开发工具类,开发必备,日期处理工具类,IO流转换工具类,打印日志工具类,屏幕,字符串工具类,Toast工具类,弹框工具类.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。

    java字符串中${}或者{}等的占位符替换工具类

    3. 字符串的处理:工具类需要能够正确地处理字符串中的占位符和普通字符。 在工具类的实现中,使用了StringBuilder和StringBuffer等技术来提高处理性能。同时,工具类还提供了对占位符的逃逸机制,以便在需要时逃逸...

    图片转字符串工具类

    这个名为"图片转字符串工具类"的程序提供了一种便捷的方法来实现这种转换。以下将详细介绍相关知识点: 1. 图片编码:图片通常是以二进制形式存储的,包含像素颜色值、图像尺寸等信息。在图片转字符串的过程中,...

    字符串过滤工具类,不错的类

    3. **处理策略**:过滤工具类提供的处理策略可能包括替换(用其他字符或字符串替换关键词)、删除(移除关键词)、标记(添加特殊标记表明存在关键词)等。不同的处理方式适应不同的业务需求,例如在论坛中,可能会...

    时间,字符串常用工具类

    字符串处理是编程中非常常见的任务,因此,一个字符串工具类会包含许多对字符串进行操作的方法。这可能包括字符串的格式化、分割、连接、查找和替换、去除空白字符、大小写转换、检查是否符合特定模式(如邮箱格式...

    JAVA中处理字符串的类

    标题提到的“JAVA中处理字符串的类”很可能就是一个这样的自定义工具类,它集成了对字符串进行各种操作的方法,旨在简化编程工作。 在Java中,最常用的字符串类是`String`。`String`类是不可变的,意味着一旦创建了...

    json工具类,java日期转换,字符串转换等各种工具类

    在Java编程中,工具类(Util Classes)是程序员日常工作中不可或缺的部分,它们提供了一系列静态方法,用于执行常见的任务,如JSON解析、日期处理、字符串操作等。以下是对标题和描述中涉及的知识点的详细说明: 1....

    C# 常用工具类 日志操作(log4net) 配置管理、字符串工具、DateTime工具、图片工具、文件工具、加密工具 等

    这些工具类通常包含对特定任务的封装,如日志记录、配置管理、字符串处理、日期时间操作、图像处理、文件操作以及安全相关的加密算法。下面将详细解释这些工具类的主要功能和应用场景。 1. **日志操作(log4net)**: ...

    日期处理工具类

    "日期处理工具类"通常是指一个自定义的类,它封装了一些常用的方法,例如日期格式化、字符串转换为日期以及对日期进行加减操作。这个类可能是开发者为了提高代码复用性和简化日期处理逻辑而创建的。 首先,让我们...

    导出工具类和字符串简易处理工具类和API文档

    在IT开发过程中,工具类和字符串处理工具是程序员日常工作中不可或缺的部分。本资源提供了一个名为"StringUtil"的自定义工具类,以及一个用于Excel导出的功能。这些工具可以帮助开发者简化代码,提高效率,同时附带...

    字符编码转换处理工具

    "字符编码转换处理工具"是一款实用的软件,专为处理汉字和字母在不同编码体系之间的转换问题而设计,它支持十六进制、二进制以及ANSI码等多种编码形式。 首先,我们要理解什么是字符编码。字符编码是一种规则,它将...

    被爱可以字符串处理工具注册机

    在IT行业中,字符串处理工具是程序员和数据分析师日常工作中不可或缺的一部分。这些工具帮助用户进行文本操作,例如查找、替换、格式化、加密和解密等。"被爱可以字符串处理工具"显然是一款专为此目的设计的软件,它...

Global site tag (gtag.js) - Google Analytics