字符串处理类 TextUtils

一  TextUtils  简介

      TextUtils  是android 提供的字符串处理类(android.text.TextUtils)。 


二  TextUtils  的重要方法

       1)  将字符从此字符串复制到目标字符数组

    public static void getChars(CharSequence s, int start, int end,
                            char[] dest, int destoff)
    s: 源字符串
    start: 复制字符串的开始
    end: 复制字符串的结尾
    dest: 目标字符串 (复制到此字符串)
    destoff: 目标字符串的起始偏移量


    2) 在字符串 s 中搜索 字符 ch, 从 start 开始搜索, 到end结束

    public static int indexOf(CharSequence s, char ch, int start, int end) 
返回字符ch 的位置

    3) 检查两个字符串是否匹配

    public static boolean regionMatches(CharSequence one, int toffset,
                                    CharSequence two, int ooffset,
                                    int len)
4) 从源字符串中取出一个子字符串

    public static String substring(CharSequence source, int start, int end) 


    5) 比较字符串a 和b 是否相同。
    public static boolean equals(CharSequence a, CharSequence b) 


你可能感兴趣的:(字符串处理类 TextUtils)