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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stringutil.java

?? 解觖java技術中后臺無法上傳數給的情況
?? JAVA
字號:
/*
 * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/util/StringUtil.java,v 1.27 2006/04/15 02:59:20 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.27 $
 * $Date: 2006/04/15 02:59:20 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2006 by MyVietnam.net
 *
 * All copyright notices regarding MyVietnam and MyVietnam CoreLib
 * MUST remain intact in the scripts and source code.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Correspondence and Marketing Questions can be sent to:
 * info at MyVietnam net
 *
 * @author: Minh Nguyen  
 * @author: Mai  Nguyen  
 */
package net.myvietnam.mvncore.util;

import net.myvietnam.mvncore.exception.BadInputException;
import java.util.*;
import net.myvietnam.mvncore.filter.DisableHtmlTagFilter;
/**
 * @todo:  add option for SHORT_STRING_LENGTH
 */
public final class StringUtil {

    private StringUtil() {//prevent instantiation
    }

    private static final int SHORT_STRING_LENGTH = 100;

    /**
     * This method trim the input variable, so if it contains only spaces,
     * then it will be empty string, then we have 0 token :-)
     * The returned value is never null. If the input String is null, an
     * empty String array will be returned
     * All tokens are trimed before returning
     */
    public static String[] getStringArray(String inputValue, String delim) {
        if (inputValue == null) inputValue = "";
        inputValue = inputValue.trim();// very important
        java.util.StringTokenizer t = new java.util.StringTokenizer(inputValue, delim);
        String[] ret = new String[t.countTokens()];
        int index = 0;
        while(t.hasMoreTokens()) {
            String token = t.nextToken().trim();
            // check for valid value here if needed
            ret[index] = token;
            index++;
        }
        return ret;
    }

    public static String[] getStringArrays(String to, String cc, String bcc, String delim) {
        String[] toMail = getStringArray(to, delim);
        String[] ccMail = getStringArray(cc, delim);
        String[] bccMail= getStringArray(bcc, delim);
        String[] ret = new String[toMail.length + ccMail.length + bccMail.length];
        int index = 0;
        for (int i = 0 ; i < toMail.length; i++) {
            ret[index] = toMail[i];
            index++;
        }
        for (int i = 0; i < ccMail.length; i++) {
            ret[index] = ccMail[i];
            index++;
        }
        for (int i = 0; i < bccMail.length; i++) {
            ret[index] = bccMail[i];
            index++;
        }
        return ret;
    }

    public static String[] getDiffStringArrays(String to, String cc, String bcc, String delim) {
        String[] toMail = getStringArray(to, delim);
        String[] ccMail = getStringArray(cc, delim);
        String[] bccMail= getStringArray(bcc, delim);
        //String[] ret = new String[t.countTokens()];
        Set set = new HashSet();
        //int index = 0;
        for (int i = 0 ; i < toMail.length; i++) {
            set.add(toMail[i]);
        }
        for (int i = 0; i < ccMail.length; i++) {
            set.add(ccMail[i]);
        }
        for (int i = 0; i < bccMail.length; i++) {
            set.add(bccMail[i]);
        }
        return (String[])set.toArray(new String[0]);
    }

    /**
     * 
     * 判斷字符串是否為空,為空返回"";
     */
    public static String getEmptyStringIfNull(String str) {
        if (str == null) return "";
        return str;
    }

    /**
     * This method accepts name with char, number or '_' or '.'
     * <p>
     * This method should be used to check all LoginName input from user for security.
     * @todo: use StringBuffer
     */
    public static void checkGoodName(String str) throws BadInputException {
        int length = str.length();
        char c = 0;

        for (int i = 0; i < length; i++) {
            c = str.charAt(i);
            if ((c >= 'a') && (c <= 'z')) {
                // lower char
            } else if ((c >= 'A') && (c <= 'Z')) {
                // upper char
            } else if ((c >= '0') && (c <= '9')/* && (i != 0)*/) {
                // numeric char
            } else if (((c == '_') || (c == '.') || (c == '@')) && (i != 0)) {
                // _ char
            // If you need to allow non-ASCII chars, please uncomment the below "else if"
            // However, this is not recommended since there will be potential security
            } else if (c >= 0x80) { 
                // by huxn allow NON-ASCII char
            } else {
                // not good char, throw an BadInputException
                //@todo : localize me
                throw new BadInputException("The string '" + DisableHtmlTagFilter.filter(str) + "' is not a good name. Reason: character '" + c + "' is not allowed.");
            }
        }// for
    }

    /**
     * Get the shorter string, the max length is defined as SHORT_STRING_LENGTH
     * @param str String the input string
     * @return String the sorter string, with the max length = SHORT_STRING_LENGTH
     */
    public static String getShorterString(String str) {
        return getShorterString(str, SHORT_STRING_LENGTH);
    }

    /**
     * Get the shorter string, the current implementation check the
     * last occurrence of Character.isWhitespace(currentChar) as the break
     * @param str String the input string
     * @param maxLength int the max length of the shorter string
     * @return String the string after being making shorter
     */
    public static String getShorterString(String str, int maxLength) {

        if (maxLength < 0) throw new IllegalArgumentException("The maxLength < 0 is not allowed.");
        if (str == null) {
            return "";
        }
        if (str.length() <= maxLength) {
            return str;
        }
        String s = str.substring(0, maxLength);
        char currentChar;
        int index;
        for (index = s.length() - 1; index >= 0; index--) {
            currentChar = s.charAt(index);
            if (Character.isWhitespace(currentChar)) {
                break;
            }
        }
        String shortString = s.substring(0, index + 1);
        return shortString + "...";
    }

    /**
     * Get the shorter string, this is the old implementation before 4 Otc, 2004.
     * This implementation does not check the space as the break one.
     * @param str String the input string
     * @param maxLength int the max length of the shorter string
     * @return String the string after being making shorter
     */
    public static String getShorterStringIgnoreSpace(String str, int maxLength) {
        if (maxLength < 0) throw new IllegalArgumentException("The maxLength < 0 is not allowed.");
        if (str == null) return "";
        if (str.length() <= maxLength) return str;
        return str.substring(0, maxLength) + "...";
    }

    /**
     * Replace the occured char to a String
     * @param input String the input string
     * @param from char the char that is used to search
     * @param to String the string that will replace the char
     * @return String the string after being replaced
     */
    public static String replace(String input, char from, String to) {
        if (input == null) {
            return null;
        }

        char[] s = input.toCharArray();
        int length = s.length;
        StringBuffer ret = new StringBuffer(length * 2);

        for (int i = 0; i < length; i++) {
            if (s[i] == from) {
                ret.append(to);
            } else {
                ret.append(s[i]);
            }
        }// for
        return ret.toString();
    }

    /**
     * This method can be replaced by getStringArray
     */
    public static Collection getSeparateString(String strContent, String pattern) {
        int beginIndex = 0;
        Collection coResult = new ArrayList();
        String result;
        int position = strContent.indexOf(pattern, beginIndex); // Get the first position
        while (position != -1) {
            result = strContent.substring(beginIndex, position);
            if (!result.trim().equals("")) {
                coResult.add(result);
            }
            beginIndex = position + pattern.length(); //we add the length of the partern such as ';'
            position = strContent.indexOf(pattern, beginIndex);
        }

        return coResult;
    }

    /**
     * Convert a password to a hidden format, usually the asterisk character is used,
     * such as 'secret' is converted to '******'
     *
     * @param password String the input password that need to convert to hidden format
     * @return String the password after being converted to the hidden format
     */
    public static String getHiddenPassword(String password) {
        password = getEmptyStringIfNull(password);
        int length = password.length();
        if (length == 0) return password;
        StringBuffer hiddenPassword = new StringBuffer(length);
        for (int i = 0; i < length; i++) {
            hiddenPassword.append('*');
        }
        return hiddenPassword.toString();
    }

    // for test only
    public static void main(String[] args) throws Exception {
        //String[] s = getStringArray("  fasg;,   zdgsag, ,,", ",");
//        String[] s = getStringArray("  fasg  ", ",");
//        System.out.println("length = " + s.length);
//        for (int i = 0; i < s.length; i++) {
//            System.out.println("" + i + " : " + s[i]);
//        }

        String s1 = "   abc das\n\n\n\n\ndasd    asd   adad   as   das   as   da    adas        da     sd    ad  as  sa  das  das   d a            .";
        System.out.println("r = [" + StringUtil.getShorterString(s1, 22) + "]");
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品99999| 亚洲国产视频在线| 国产高清不卡一区| 在线观看中文字幕不卡| 亚洲国产精品尤物yw在线观看| 欧洲av在线精品| 精品国产乱码久久久久久老虎| 日韩欧美亚洲一区二区| 国产精品毛片大码女人| 色婷婷综合激情| 国产成人超碰人人澡人人澡| 日本不卡免费在线视频| 中文字幕亚洲成人| 成人黄色免费短视频| 日韩av高清在线观看| 亚洲一区在线观看免费观看电影高清| 久久久久青草大香线综合精品| 欧美四级电影在线观看| 91一区二区三区在线观看| 国产成人无遮挡在线视频| 激情综合色综合久久综合| 色婷婷激情综合| 成人小视频在线| 欧美精品乱人伦久久久久久| 久久久久久久久岛国免费| 99久久精品国产一区二区三区 | 在线看不卡av| 日韩一区二区三区观看| 最新国产精品久久精品| 黄色精品一二区| 制服丝袜一区二区三区| 中文字幕一区二区5566日韩| 加勒比av一区二区| 91麻豆精品国产91久久久使用方法| 国产欧美精品日韩区二区麻豆天美| 91九色02白丝porn| 成人欧美一区二区三区黑人麻豆| 日本美女一区二区| 欧美亚洲一区二区在线| 亚洲欧美中日韩| eeuss鲁片一区二区三区在线观看| 日韩avvvv在线播放| 色综合久久久久久久久久久| 国产精品国产自产拍在线| 国产精品一二三四五| 欧美激情一区二区在线| 国产乱人伦精品一区二区在线观看| 美女视频一区二区| 制服丝袜中文字幕一区| 麻豆freexxxx性91精品| 日韩欧美二区三区| 国产成人av一区二区三区在线| 久久久不卡网国产精品一区| 精品国产亚洲在线| 国产精品自产自拍| 日韩毛片视频在线看| 色婷婷激情一区二区三区| 亚洲午夜一区二区| 欧美大片一区二区三区| 欧美韩国日本综合| 99精品视频在线免费观看| 有坂深雪av一区二区精品| 欧美日韩国产综合一区二区三区 | 成人小视频在线| 在线观看av一区| 精品一区二区国语对白| 亚洲一区中文日韩| 国产很黄免费观看久久| 26uuu精品一区二区在线观看| 国模无码大尺度一区二区三区| 久久不见久久见免费视频7| 久久精品在线免费观看| 欧美影院一区二区| 寂寞少妇一区二区三区| 午夜在线成人av| 国产欧美va欧美不卡在线| 欧美精品日韩精品| 色婷婷综合久久久中文一区二区| 免费精品视频在线| 亚洲精品菠萝久久久久久久| 国产欧美日韩激情| 欧美变态tickle挠乳网站| 欧美在线看片a免费观看| 91国偷自产一区二区开放时间| 久久99最新地址| 捆绑调教一区二区三区| 亚洲妇熟xx妇色黄| 亚洲成人一区在线| 亚洲欧洲另类国产综合| 国产精品福利一区二区| 欧美国产一区二区| 国产日韩精品视频一区| 欧美精品一区二区三区在线| 欧美一级久久久久久久大片| 91啪亚洲精品| 在线播放一区二区三区| 奇米影视一区二区三区| 免费在线观看精品| 极品美女销魂一区二区三区 | 国产精品国产三级国产普通话蜜臀| 日韩三级在线免费观看| 精品福利二区三区| 国产精品毛片久久久久久久| 中文字幕一区二区三| 色哟哟精品一区| 91精品国产品国语在线不卡| 日韩精品专区在线影院观看| 国产拍欧美日韩视频二区| 亚洲欧美一区二区在线观看| 性做久久久久久| 国产视频一区二区在线| 亚洲欧美在线视频观看| 日本欧洲一区二区| 97精品视频在线观看自产线路二| 91精品办公室少妇高潮对白| 91精品蜜臀在线一区尤物| 日韩一区日韩二区| 国产精品18久久久| 91精品福利在线一区二区三区 | 国产高清精品网站| 26uuu精品一区二区三区四区在线| 色一区在线观看| 久久免费美女视频| 久久精品国产亚洲aⅴ| 91福利视频久久久久| 国产成人免费高清| 欧美一区永久视频免费观看| 亚洲精品日日夜夜| xnxx国产精品| 韩国v欧美v日本v亚洲v| 欧美日韩视频在线第一区| 国产精品理伦片| 99r国产精品| 亚洲欧美日韩在线播放| 成人av在线影院| 亚洲一区精品在线| 久久久精品欧美丰满| 性做久久久久久免费观看| 91精品办公室少妇高潮对白| 日本久久电影网| 欧美美女网站色| 一区二区三区日韩精品| 麻豆视频观看网址久久| 成人av在线播放网站| 精品一区二区三区久久久| 成人性生交大片免费看在线播放| 欧美日韩中文精品| 中文字幕一区二区三区不卡| 国产一二精品视频| 国内成人自拍视频| 国产精品一区二区黑丝| 久久嫩草精品久久久精品一| 成人黄色免费短视频| 日韩精品欧美精品| 欧美成人免费网站| 成人一二三区视频| 亚洲444eee在线观看| 国产午夜亚洲精品不卡| 欧美高清视频在线高清观看mv色露露十八 | 亚洲国产精品精华液2区45| av中文字幕在线不卡| 午夜精品成人在线视频| 国产视频一区在线观看| 欧洲av在线精品| av在线一区二区三区| 国产在线精品一区二区夜色| 一区二区久久久久久| 久久精品视频免费观看| 5月丁香婷婷综合| 色婷婷国产精品| 日韩色视频在线观看| 欧美色成人综合| 成人av手机在线观看| 国产成人自拍在线| 黄页视频在线91| 亚洲国产精品精华液网站| 久久欧美一区二区| 精品乱人伦一区二区三区| 国产乱子伦视频一区二区三区| 婷婷成人综合网| 亚洲成人免费视| 亚洲激情欧美激情| 综合婷婷亚洲小说| 国产日韩欧美电影| 中文字幕欧美激情| 国产精品久久久久一区二区三区| 国产人成一区二区三区影院| 国产亚洲精品aa| 亚洲视频在线一区| 亚洲五月六月丁香激情| 日韩激情一二三区| 国产成人在线网站| 色综合久久88色综合天天6 | 精品免费99久久| 一本一道波多野结衣一区二区| 91亚洲永久精品| 欧美成人综合网站| 国产精品不卡在线| 乱中年女人伦av一区二区| 国产成人免费在线观看|