亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? stringutils.java

?? 個(gè)人Blog java編寫(xiě)的Blog可以直接使用!
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
 *  StringUtils.java
 *  
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *  
 *  Author: Winter Lau (javayou@gmail.com)
 *  http://dlog4j.sourceforge.net
 */
package com.liusoft.dlog4j.util;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.util.NodeList;

/**
 * 字符串工具集合
 * @author Winter Lau
 */
public class StringUtils extends org.apache.commons.lang.StringUtils {

	/**
	 * 如果系統(tǒng)中存在舊版本的數(shù)據(jù),則此值不能修改,否則在進(jìn)行密碼解析的時(shí)候出錯(cuò)
	 */
    private static final String PASSWORD_CRYPT_KEY = "__jDlog_";
	private final static String DES = "DES";
    private final static String ISO8859_1 = "8859_1";
	
	private final static NodeFilter nodeFilter = new NodeFilter() {
		public boolean accept(Node node) {
			return true;
		}
	};

	/**
	 * retrive the extend name of the given filename
	 * @param fn
	 * @return
	 */
	public static String getFileExtend(String fn){
		if(isEmpty(fn))
			return null;
		int idx = fn.lastIndexOf('.')+1;
		if(idx==0 || idx >= fn.length())
			return null;
		return fn.substring(idx);
	}
	
	/**
	 * 將字符串用ch分割并放入隊(duì)列
	 * @param tags
	 * @param ch
	 * @return
	 */
	public static List stringToList(String tags, String ch){
		if(tags==null)
			return null;
		ArrayList tagList = new ArrayList();
		StringTokenizer st = new StringTokenizer(tags, ch);
		while(st.hasMoreElements()){
			tagList.add(st.nextToken());
		}
		return tagList;
	}

	/**
	 * 將字符串用空格分割并放入隊(duì)列
	 * @param tags
	 * @return
	 */
	public static List stringToList(String tags){
		if(tags==null)
			return null;
		ArrayList tagList = new ArrayList();
		StringTokenizer st = new StringTokenizer(tags);
		while(st.hasMoreElements()){
			tagList.add(st.nextToken());
		}
		return tagList;
	}

	/**
	 * BASE64編碼
	 * @param s
	 * @return String
	 */
	public static byte[] enBASE64(byte[] bytes){
		return Base64Code.encode(bytes);
	}
	/**
	 * BASE64反編碼
	 * @param bytes
	 * @return byte[]
	 */
	public static byte[] deBASE64(byte[] bytes){
		return Base64Code.decode(bytes);
	}
	/**
	 * BASE64編碼
	 * @param s
	 * @return String
	 */
	public static String enBASE64(String s) {
		if (s != null) {
			byte abyte0[] = s.getBytes();
			abyte0 = Base64Code.encode(abyte0);
			s = new String(abyte0);
			return s;
		} 
		return null;
	}
	/**
	 * BASE64反編碼
	 * @param s
	 * @return String
	 */
	public static String deBASE64(String s) {
		if (s != null) {
			byte abyte0[] = s.getBytes();
			abyte0 = Base64Code.decode(abyte0);
			s = new String(abyte0);
			abyte0 = null;
			return s;
		} 
		return null;
	}
	/**
	 * HTML輸出內(nèi)容格式轉(zhuǎn)換
	 * @param content
	 * @return
	 */
	public static String formatContent(String content) {
        if(content==null)
            return "";        
		String randomStr = String.valueOf(System.currentTimeMillis());
		String html = StringUtils.replace(content," ",randomStr);		
		html = StringUtils.replace(html, "&", "&");
		html = StringUtils.replace(html, "'", "'");
		html = StringUtils.replace(html, "\"", """);
		html = StringUtils.replace(html, "\t", "  ");// 替換跳格
		html = StringUtils.replace(html, " ", " ");// 替換空格
		html = StringUtils.replace(html, "<", "&lt;");
		html = StringUtils.replace(html, ">", "&gt;");
		return StringUtils.replace(html,randomStr,"&nbsp;").trim();
	}

    /**
	  * 抽取純文本信息
	  * @param inputHtml
	  * @return
	  */
	public static String extractText(String inputHtml) throws Exception {
		StringBuffer text = new StringBuffer();
		Parser parser = new Parser();
		parser.setInputHTML(new String(inputHtml.getBytes(),ISO8859_1));
		//Parser parser = Parser.createParser(new String(inputHtml.getBytes(),ISO8859_1));
		//遍歷所有的節(jié)點(diǎn)
		NodeList nodes = parser.extractAllNodesThatMatch(nodeFilter);
		for(int i=0;i<nodes.size();i++){
			Node node = nodes.elementAt(i);
			text.append(new String(node.toPlainTextString().getBytes(ISO8859_1)));
		}
		return text.toString();
	}

	/**
	 * 判斷是不是一個(gè)合法的電子郵件地址
	 * @param email
	 * @return
	 */
	public static boolean isEmail(String email){
		if(email==null)
			return false;
		email = email.trim();
		if(email.indexOf(' ')!=-1)
			return false;
		
		int idx = email.indexOf('@');
		if(idx==-1 || idx==0 || (idx+1)==email.length())
			return false;
		if(email.indexOf('@', idx+1)!=-1)
			return false;
        if(email.indexOf('.')==-1)
            return false;
		return true;
		/*
		Pattern emailer;
		if(emailer==null){
			String check = "^([a-z0-9A-Z]+[-|\\._]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
			emailer = Pattern.compile(check);
		}
	    Matcher matcher = emailer.matcher(email);
	    return matcher.matches();
		*/
	}
	
	/**
	 * 判斷字符串是否是一個(gè)IP地址
	 * @param addr
	 * @return
	 */
	public static boolean isIPAddr(String addr){
		if(isEmpty(addr))
			return false;
		String[] ips = split(addr, '.');
		if(ips.length != 4)
			return false;
		try{
			int ipa = Integer.parseInt(ips[0]);
			int ipb = Integer.parseInt(ips[1]);
			int ipc = Integer.parseInt(ips[2]);
			int ipd = Integer.parseInt(ips[3]);
			return ipa >= 0 && ipa <= 255 && ipb >= 0 && ipb <=255 && ipc >= 0
					&& ipc <= 255 && ipd >= 0 && ipd <=255;
		}catch(Exception e){}
		return false;
	}
	/**
	 * 加密
	 * @param src 數(shù)據(jù)源
	 * @param key 密鑰,長(zhǎng)度必須是8的倍數(shù)
	 * @return	  返回加密后的數(shù)據(jù)
	 * @throws Exception
	 */
	public static byte[] encrypt(byte[] src, byte[] key)
		throws Exception {
		//		DES算法要求有一個(gè)可信任的隨機(jī)數(shù)源
		SecureRandom sr = new SecureRandom();
		// 從原始密匙數(shù)據(jù)創(chuàng)建DESKeySpec對(duì)象
		DESKeySpec dks = new DESKeySpec(key);
		// 創(chuàng)建一個(gè)密匙工廠,然后用它把DESKeySpec轉(zhuǎn)換成
		// 一個(gè)SecretKey對(duì)象
		SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
		SecretKey securekey = keyFactory.generateSecret(dks);
		// Cipher對(duì)象實(shí)際完成加密操作
		Cipher cipher = Cipher.getInstance(DES);
		// 用密匙初始化Cipher對(duì)象
		cipher.init(Cipher.ENCRYPT_MODE, securekey, sr);
		// 現(xiàn)在,獲取數(shù)據(jù)并加密
		// 正式執(zhí)行加密操作
		return cipher.doFinal(src);
	}
	
	/**
	 * 解密
	 * @param src	數(shù)據(jù)源
	 * @param key	密鑰,長(zhǎng)度必須是8的倍數(shù)
	 * @return		返回解密后的原始數(shù)據(jù)
	 * @throws Exception
	 */
	public static byte[] decrypt(byte[] src, byte[] key)
		throws Exception {
		//		DES算法要求有一個(gè)可信任的隨機(jī)數(shù)源
		SecureRandom sr = new SecureRandom();
		// 從原始密匙數(shù)據(jù)創(chuàng)建一個(gè)DESKeySpec對(duì)象
		DESKeySpec dks = new DESKeySpec(key);
		// 創(chuàng)建一個(gè)密匙工廠,然后用它把DESKeySpec對(duì)象轉(zhuǎn)換成
		// 一個(gè)SecretKey對(duì)象
		SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
		SecretKey securekey = keyFactory.generateSecret(dks);
		// Cipher對(duì)象實(shí)際完成解密操作
		Cipher cipher = Cipher.getInstance(DES);
		// 用密匙初始化Cipher對(duì)象
		cipher.init(Cipher.DECRYPT_MODE, securekey, sr);
		// 現(xiàn)在,獲取數(shù)據(jù)并解密
		// 正式執(zhí)行解密操作
		return cipher.doFinal(src);
	}
    /**
     * 數(shù)據(jù)解密
     * @param data
     * @param key 密鑰
     * @return
     * @throws Exception
     */
    public final static String decrypt(String data, String key){
    	if(data!=null)
        try {
            return new String(decrypt(hex2byte(data.getBytes()),key.getBytes()));
        }catch(Exception e) {
        	e.printStackTrace();
        }
        return null;
    }
    /**
     * 數(shù)據(jù)加密
     * @param data
     * @param key 密鑰
     * @return
     * @throws Exception
     */
    public final static String encrypt(String data, String key){
    	if(data!=null)
        try {
            return byte2hex(encrypt(data.getBytes(),key.getBytes()));
        }catch(Exception e) {
        	e.printStackTrace();
        }
        return null;
    }
    /**
     * 密碼解密
     * @param data
     * @return
     * @throws Exception
     */
    public final static String decryptPassword(String data){
    	if(data!=null)
        try {
            return new String(decrypt(hex2byte(data.getBytes()),PASSWORD_CRYPT_KEY.getBytes()));
        }catch(Exception e) {
        	e.printStackTrace();
        }
        return null;
    }
    /**
     * 密碼加密
     * @param password
     * @return
     * @throws Exception
     */
    public final static String encryptPassword(String password){
    	if(password!=null)
        try {
            return byte2hex(encrypt(password.getBytes(),PASSWORD_CRYPT_KEY.getBytes()));
        }catch(Exception e) {
        	e.printStackTrace();
        }
        return null;
    }
	/**
	 * 二行制轉(zhuǎn)字符串
	 * @param b
	 * @return
	 */
    public static String byte2hex(byte[] b) {
		String hs = "";
		String stmp = "";
		for (int n = 0; b!=null && n < b.length; n++) {
			stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
			if (stmp.length() == 1)
				hs = hs + "0" + stmp;
			else
				hs = hs + stmp;
		}
		return hs.toUpperCase();
	}
    
    public static byte[] hex2byte(byte[] b) {
        if((b.length%2)!=0)
            throw new IllegalArgumentException("長(zhǎng)度不是偶數(shù)");
		byte[] b2 = new byte[b.length/2];
		for (int n = 0; n < b.length; n+=2) {
		    String item = new String(b,n,2);
		    b2[n/2] = (byte)Integer.parseInt(item,16);
		}
        return b2;

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人中文在线| 国产一区二区三区蝌蚪| 麻豆精品一区二区| 91麻豆文化传媒在线观看| 精品区一区二区| 亚洲妇女屁股眼交7| 波多野结衣在线一区| 2023国产精品自拍| 日韩高清不卡一区| 欧美偷拍一区二区| 亚洲激情在线播放| caoporn国产精品| 国产日韩欧美激情| 国产老妇另类xxxxx| 4438x亚洲最大成人网| 亚洲成人av电影在线| www.综合网.com| 国产三级久久久| 国产精品12区| 国产偷国产偷亚洲高清人白洁| 蜜桃av一区二区| 日韩一区二区中文字幕| 石原莉奈在线亚洲二区| 欧美天堂亚洲电影院在线播放| 亚洲视频在线一区二区| 不卡一区在线观看| 国产精品成人一区二区三区夜夜夜| 国产在线视频一区二区| 久久影院电视剧免费观看| 毛片av一区二区| xf在线a精品一区二区视频网站| 免费观看在线色综合| 欧美videofree性高清杂交| 免费成人你懂的| 久久综合五月天婷婷伊人| 久草这里只有精品视频| 久久久精品欧美丰满| 国产精品白丝jk白祙喷水网站| 精品国产麻豆免费人成网站| 国产一区二区看久久| 国产肉丝袜一区二区| caoporn国产精品| 亚洲精品一二三四区| 精品视频一区三区九区| 日韩中文欧美在线| 337p日本欧洲亚洲大胆色噜噜| 国产精品香蕉一区二区三区| 国产精品久久一卡二卡| 在线一区二区观看| 毛片基地黄久久久久久天堂| 久久久久国产精品免费免费搜索| 国产成人综合精品三级| 最近中文字幕一区二区三区| 欧美亚洲图片小说| 经典三级一区二区| 亚洲欧洲日韩av| 欧美日韩一区二区三区四区| 久久精品免费观看| 国产精品美女久久久久aⅴ| 欧美综合视频在线观看| 激情综合色播五月| 国产精品色哟哟网站| 欧美丝袜第三区| 国产精品一区二区黑丝| 亚洲男人天堂av网| 久久综合精品国产一区二区三区 | 一区二区三区精密机械公司| 日韩一区二区三区高清免费看看| 国产成人午夜精品影院观看视频 | 国产麻豆精品在线观看| 亚洲欧美色综合| 精品毛片乱码1区2区3区| 97se亚洲国产综合在线| 美日韩黄色大片| 一区二区三区影院| 久久久久久久av麻豆果冻| 欧美日韩在线电影| www.66久久| 韩国v欧美v亚洲v日本v| 亚洲一区二区免费视频| 欧美国产禁国产网站cc| 日韩欧美国产综合| 欧美丝袜自拍制服另类| eeuss鲁片一区二区三区在线看| 麻豆91精品视频| 亚洲一区二区在线视频| 国产精品视频一二三| 日韩视频中午一区| 欧美日本一区二区三区| 91在线观看免费视频| 福利一区二区在线| 国模无码大尺度一区二区三区| 亚瑟在线精品视频| 一个色综合网站| 国产精品―色哟哟| 日韩欧美国产小视频| 欧美精品九九99久久| 欧美亚洲综合另类| 色老头久久综合| 一本一本大道香蕉久在线精品| 国产精品亚洲综合一区在线观看| 日本美女一区二区三区视频| 亚洲国产精品久久久久秋霞影院| 亚洲另类在线制服丝袜| 亚洲天堂网中文字| ...xxx性欧美| 亚洲欧洲精品一区二区三区不卡| 国产婷婷精品av在线| 久久新电视剧免费观看| 久久网站最新地址| 久久久噜噜噜久噜久久综合| 精品国产伦一区二区三区免费| 日韩精品一区二区三区在线| 日韩欧美国产综合一区| 久久综合一区二区| 欧美国产丝袜视频| 成人欧美一区二区三区黑人麻豆| 国产精品美女www爽爽爽| 成人免费视频在线观看| 亚洲激情男女视频| 午夜久久久影院| 日韩国产精品久久久久久亚洲| 奇米综合一区二区三区精品视频| 久久国产精品色婷婷| 黄色小说综合网站| zzijzzij亚洲日本少妇熟睡| 成人av资源在线| 色噜噜狠狠成人中文综合| 欧美日韩激情一区二区三区| 欧美一区二区三区男人的天堂| 欧美第一区第二区| 亚洲国产精品精华液2区45| 国产精品动漫网站| 亚洲成av人片一区二区三区| 日本亚洲天堂网| 国产福利一区二区| 色综合久久久久综合99| 欧美精品在线观看一区二区| 精品国产一区二区三区av性色 | 亚洲精品一区二区三区精华液 | 久久久蜜臀国产一区二区| 综合久久综合久久| 天天影视涩香欲综合网| 国产精品综合一区二区三区| 99国产欧美另类久久久精品 | 色综合久久久久综合体桃花网| 91精品午夜视频| 国产精品视频免费看| 亚洲成av人片在线观看无码| 国产精品羞羞答答xxdd| 色哟哟在线观看一区二区三区| 91精品国产欧美一区二区18 | 欧美一区二区成人6969| 国产三级精品在线| 亚洲国产精品影院| 国产成人夜色高潮福利影视| 欧美日韩一区二区在线视频| 国产免费观看久久| 天天操天天干天天综合网| 国产成人av一区二区三区在线| 欧美色区777第一页| 国产亚洲精品bt天堂精选| 午夜精品一区在线观看| 在线观看亚洲精品视频| 日韩欧美一区二区视频| 有码一区二区三区| 国产99久久久精品| 日韩一区二区三区免费看| 亚洲欧美国产三级| 国产成人a级片| 欧美va亚洲va在线观看蝴蝶网| 亚洲自拍另类综合| 成人动漫av在线| 欧美mv日韩mv| 午夜精品123| 色噜噜久久综合| 亚洲欧美在线视频观看| 国产精品一区二区三区四区| 日韩欧美国产一区二区三区 | 亚洲精品一卡二卡| 成人毛片老司机大片| 精品三级在线观看| 日本成人在线网站| 欧美浪妇xxxx高跟鞋交| 一区二区三区四区亚洲| 懂色av噜噜一区二区三区av| 精品成人免费观看| 精油按摩中文字幕久久| 日韩一区二区三区在线观看| 性做久久久久久免费观看欧美| 色婷婷国产精品| 亚洲丝袜制服诱惑| 色综合天天天天做夜夜夜夜做| 国产精品麻豆99久久久久久| 丁香啪啪综合成人亚洲小说| 国产欧美日韩三区| 本田岬高潮一区二区三区| 国产精品国产三级国产普通话三级| 国产一区二区不卡在线| 久久综合精品国产一区二区三区|