Android Open Source - android-common-utility String Util






From Project

Back to project page android-common-utility.

License

The source code is released under:

Apache License

If you think the Android project android-common-utility listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.xckevin.android.util;
/*from  w  ww .jav  a2  s.com*/
import java.util.regex.Pattern;

public class StringUtil {

    // email
    private final static Pattern emailer = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");

    /**
     * if string is empty
     *
     * @param input
     * @return boolean
     */
    public static boolean isEmpty(String input) {
        if (input == null || "".equals(input))
            return true;

        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
                return false;
            }
        }
        return true;
    }

    /**
     * if email is valid
     *
     * @param email
     * @return
     */
    public static boolean isEmail(String email) {
        if (email == null || email.trim().length() == 0)
            return false;
        return emailer.matcher(email).matches();
    }

    /**
     * ???????????
     *
     * @param input
     * @return
     */
    public static String toDBC(String input) {
        char[] c = input.toCharArray();
        for (int i = 0; i < c.length; i++) {
            if (c[i] == 12288) {
                c[i] = (char) 32;
                continue;
            }
            if (c[i] > 65280 && c[i] < 65375)
                c[i] = (char) (c[i] - 65248);
        }
        return new String(c);
    }
}




Java Source Code List

com.xckevin.android.Env.java
com.xckevin.android.util.AppUtil.java
com.xckevin.android.util.FileUtils.java
com.xckevin.android.util.MD5.java
com.xckevin.android.util.StringUtil.java
com.xckevin.android.widget.AutoSwitchImageView.java
com.xckevin.android.widget.PullToLoadListView.java