<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 33,  comments - 17,  trackbacks - 0
     1/**
     2  * 判斷是不是合法手機
     3  * handset 手機號碼
     4  */

     5 public static boolean isHandset(String handset) {
     6  try {
     7   if(!handset.substring(0,1).equals("1")) {
     8    return false;
     9   }

    10   if (handset==null || handset.length()!=11{
    11    return false;
    12   }

    13   String check = "^[0123456789]+$";
    14   Pattern regex = Pattern.compile(check);
    15   Matcher matcher = regex.matcher(handset);
    16   boolean isMatched = matcher.matches();
    17   if(isMatched) {
    18    return true;
    19   }
     else {
    20    return false;
    21   }

    22  }
     catch (RuntimeException e) {
    23   return false;
    24  }
     
    25 }

    26}
    27
    28
     1 /**
     2     * 將指定byte數組以16進制的形式打印到控制臺
     3     * @param hint
     4     *            String
     5     * @param b
     6     *            byte[]
     7     * @return void
     8     */

     9    public static void printHexString(String hint, byte[] b)
    10    {
    11        System.out.print(hint);
    12        for (int i = 0; i < b.length; i++)
    13        {
    14            String hex = Integer.toHexString(b[i] & 0xFF);
    15            if (hex.length() == 1)
    16            {
    17                hex = '0' + hex;
    18            }

    19            System.out.print(hex.toUpperCase() + " ");
    20        }

    21        System.out.println("");
    22    }

    23

     1/**
     2     * 全角字符轉半角字符
     3     * 
     4     * @param QJStr
     5     * @return String
     6     */

     7    public static final String QJToBJChange(String QJStr)
     8    {
     9        char[] chr = QJStr.toCharArray();
    10        String str = "";
    11        for (int i = 0; i < chr.length; i++)
    12        {
    13            chr[i] = (char) ((int) chr[i] - 65248);
    14            str += chr[i];
    15        }

    16        return str;
    17    }

     1  /**
     2     * 去掉字符串中重復的子字符串
     3     * 
     4     * @param str
     5     * @return String
     6     */

     7    private static String removeSameString(String str)
     8    {
     9        Set<String> mLinkedSet = new LinkedHashSet<String>();
    10        String[] strArray = str.split(" ");
    11        StringBuffer sb = new StringBuffer();
    12
    13        for (int i = 0; i < strArray.length; i++)
    14        {
    15            if (!mLinkedSet.contains(strArray[i]))
    16            {
    17                mLinkedSet.add(strArray[i]);
    18                sb.append(strArray[i] + " ");
    19            }

    20        }

    21        System.out.println(mLinkedSet);
    22        return sb.toString().substring(0, sb.toString().length() - 1);
    23    }

     1/**
     2     * 設置JSpinner的編輯屬性
     3     * @param spinner 目標JSpinner
     4     * @param isAllowInvalid 是否允許輸入非法值
     5     * @param isEditable 是否允許編輯
     6     */

     7    public static void setAllowsInvalid(JSpinner spinner, boolean isAllowInvalid, boolean isEditable)
     8    {
     9        JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner, "#");
    10        spinner.setEditor(editor);
    11        JFormattedTextField tf = ((JSpinner.NumberEditor)spinner.getEditor()).getTextField();
    12        tf.setEditable(isEditable);
    13        DefaultFormatterFactory factory = (DefaultFormatterFactory)tf.getFormatterFactory();
    14        NumberFormatter formatter = (NumberFormatter)factory.getDefaultFormatter();
    15        formatter.setAllowsInvalid(isAllowInvalid);
    16    }

    17

     1 /**   
     2     * 根據指定方法的參數去構造一個新的對象的拷貝并將他返回
     3     * @param obj 原始對象
     4     * @return 新對象
     5     * @throws NoSuchMethodException    
     6     * @throws InvocationTargetException    
     7     * @throws IllegalAccessException    
     8     * @throws InstantiationException    
     9     * @throws SecurityException    
    10     * @throws IllegalArgumentException    
    11     */

    12    @SuppressWarnings("unchecked")
    13    public static Object copy(Object obj) throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException,
    14                    InvocationTargetException, NoSuchMethodException
    15    {
    16        //獲得對象的類型    
    17        Class classType = obj.getClass();
    18
    19        //通過默認構造方法去創建一個新的對象,getConstructor的視其參數決定調用哪個構造方法    
    20        Object objectCopy = classType.getConstructor(new Class[]{}).newInstance(new Object[]{});
    21
    22        //獲得對象的所有屬性    
    23        Field[] fields = classType.getDeclaredFields();
    24
    25        for(int i = 0; i < fields.length; i++)
    26        {
    27            //獲取數組中對應的屬性    
    28            Field field = fields[i];
    29
    30            String fieldName = field.getName();
    31            String stringLetter = fieldName.substring(01).toUpperCase();
    32
    33            //獲得相應屬性的getXXX和setXXX方法名稱    
    34            String getName = "get" + stringLetter + fieldName.substring(1);
    35            String setName = "set" + stringLetter + fieldName.substring(1);
    36
    37            //獲取相應的方法    
    38            Method getMethod = classType.getMethod(getName, new Class[]{});
    39            Method setMethod = classType.getMethod(setName, new Class[]{field.getType()});
    40
    41            //調用源對象的getXXX()方法    
    42            Object value = getMethod.invoke(obj, new Object[]{});
    43
    44            //調用拷貝對象的setXXX()方法    
    45            setMethod.invoke(objectCopy, new Object[]{value});
    46        }

    47
    48        return objectCopy;
    49    }

    50
    51

     1//過濾特殊字符
     2public static String encoding(String src){
     3        if (src==null)
     4            return "";
     5        StringBuilder result=new StringBuilder();
     6        if (src!=null){
     7            src=src.trim();
     8            for (int pos=0;pos<src.length();pos++){
     9                switch(src.charAt(pos)){
    10                    case '\"':result.append("&quot;");break;
    11                    case '<':result.append("&lt;");break;
    12                    case '>':result.append("&gt;");break;
    13                    case '\'':result.append("&apos;");break;
    14                    case '&':result.append("&amp;");break;
    15                    case '%':result.append("&pc;");break;
    16                    case '_':result.append("&ul;");break;
    17                    case '#':result.append("&shap;");break;
    18                    case '?':result.append("&ques;");break;
    19                    default:result.append(src.charAt(pos));break;
    20                }

    21            }

    22        }

    23        return result.toString();
    24    }

    25    
    26//反過濾特殊字符
    27    public static String decoding(String src){
    28        if (src==null)
    29            return "";
    30        String result=src;
    31        result=result.replace("&quot;""\"").replace("&apos;""\'");
    32        result=result.replace("&lt;""<").replace("&gt;"">");
    33        result=result.replace("&amp;""&");
    34        result=result.replace("&pc;""%").replace("&ul""_");
    35        result=result.replace("&shap;""#").replace("&ques""?");
    36        return result;
    37    }

    38

     1 /**
     2  * 寫入日志
     3  * filePath 日志文件的路徑
     4  * code 要寫入日志文件的內容
     5  */

     6 public static boolean print(String filePath,String code) {
     7  try {
     8   File tofile=new File(filePath);
     9   FileWriter fw=new FileWriter(tofile,true);
    10   BufferedWriter bw=new BufferedWriter(fw);
    11   PrintWriter pw=new PrintWriter(bw);
    12   
    13   System.out.println(getDate()+":"+code);
    14   pw.println(getDate()+":"+code);
    15   pw.close();
    16   bw.close();
    17   fw.close();
    18   return true;
    19  }
     catch (IOException e) {
    20   return false;
    21  }

    22 }

    23

     1// 字符串匹配的算法. 
     2public String getMaxMatch(String a,String b) {   
     3        StringBuffer tmp = new StringBuffer();   
     4        String maxString = "";   
     5        int max = 0;   
     6        int len = 0;   
     7        char[] aArray = a.toCharArray();   
     8        char[] bArray = b.toCharArray();   
     9        int posA = 0;   
    10        int posB = 0;   
    11        while(posA<aArray.length-max) {   
    12            posB = 0;   
    13            while(posB<(bArray.length-max)) {                                   
    14                 if(aArray[posA]==bArray[posB]) {   
    15                      len = 1;   
    16                      tmp = new StringBuffer();   
    17                      tmp.append(aArray[posA]);                                           
    18                      while((posA+len<aArray.length)&&(posB+len<bArray.length)&&(aArray[posA+len]==bArray[posB+len])) {   
    19                           tmp.append(aArray[posA+len]);   
    20                           len++;   
    21                      }
       
    22                      if(len>max) {   
    23                            max = len;   
    24                            maxString = tmp.toString();   
    25                      }
       
    26                 }
       
    27                      posB++;   
    28            }
       
    29                      posA++;   
    30         }
               
    31            return maxString;                       
    32    }

    33
    34

    posted on 2008-07-23 17:20 scea2009 閱讀(253) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    <2008年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(1)

    隨筆分類

    隨筆檔案

    PL/SQL存儲過程與函數

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 免费A级毛片无码A∨男男| 国产一级一毛免费黄片| 亚洲色成人网站WWW永久四虎| 亚洲一区二区影院| 亚洲V无码一区二区三区四区观看 亚洲αv久久久噜噜噜噜噜 | 日本最新免费不卡二区在线| 67194成是人免费无码| 最近最好的中文字幕2019免费 | 高潮毛片无遮挡高清免费视频| 国产亚洲精品VA片在线播放| 亚洲日本va在线观看| 亚洲综合av一区二区三区不卡| 亚洲午夜精品一区二区麻豆| 亚洲色欲色欱wwW在线| 亚洲AV第一成肉网| 免费看一级一级人妻片| 一区二区三区免费高清视频| baoyu116.永久免费视频| 四虎成人精品永久免费AV| 黄色网址免费观看| 永久免费观看的毛片的网站| 亚洲 综合 国产 欧洲 丝袜 | 国产在线观看麻豆91精品免费| 中文毛片无遮挡高潮免费| 成人免费在线视频| 免费一级毛片女人图片| 久久久久国产成人精品亚洲午夜 | 国产精品99久久免费| 亚洲国产成人久久综合野外| 亚洲av中文无码乱人伦在线r▽| 日韩精品亚洲人成在线观看| 亚洲精品免费网站| 污污视频免费观看网站| 国产午夜精品免费一区二区三区 | 特黄特色大片免费| 无码人妻一区二区三区免费看| 免费视频爱爱太爽了| 免费国产在线观看不卡| 亚洲成色WWW久久网站| 亚洲无限乱码一二三四区| 亚洲youwu永久无码精品|