String 类有以下方法:

startsWith(String prefix)

boolean java.lang.String.startsWith(String prefix)

Tests if this string starts with the specified prefix.

Parameters:
prefix the prefix.
Returns:
true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise. Note also that true will be returned if the argument is an empty string or is equal to this String object as determined by the equals(Object) method.
Since:
1. 0
就是判断字符串中的后缀是否为参数prefix,如果是就返回true,如果不是就返回false。
这在安卓中可以用来识别音频文件,如mp3文件等。
对应的,还有一个方法,
endsWith(String suffix)
boolean java.lang.String.endsWith(String suffix)

Tests if this string ends with the specified suffix.

Parameters:
suffix the suffix.
Returns:
true if the character sequence represented by the argument is a
suffix of the character sequence represented by this object; false
otherwise. Note that the result will be true if the argument is the
empty string or is equal to this String object as determined by the
equals(Object)
method.
可以用来判断一个字符串是否以suffix这个参数开头。

String类的一些方法的更多相关文章

  1. 关于JAVA的String类的一些方法

    一.得到字符串对象的有关信息 1.通过调用length()方法得到String的长度. String str=”This is a String”; int len =str.length(); 2. ...

  2. C++ string 类的 find 方法实例详解

    1.C++ 中 string 类的 find 方法列表 size_type std::basic_string::find(const basic_string &__str, size_ty ...

  3. java.lang.String 类的所有方法

    java.lang.String 类的所有方法 方法摘要 char charAt(int index) 返回指定索引处的 char 值. int codePointAt(int index) 返回指定 ...

  4. Java中String类的format方法使用总结

    可参考: http://www.cnblogs.com/fsjohnhuang/p/4094777.html http://kgd1120.iteye.com/blog/1293633 String类 ...

  5. String类的split方法以及StringTokenizer

    split方法可以根据指定的表达式regex将一个字符串分割成一个子字符串数组. 它的参数有两种形式,也即:split(String regex)和split(String regex, int li ...

  6. ASP.Net string 类的扩展方法 [转]

    string 类的扩展方法列表(基本相同于 IEnumerable<T> 接口的成员列表): Aggregate<>     //累加 All<>        / ...

  7. String类的indexOf方法的用法和举例

    2017年3月3号博主第一次去郑州互联网公司面试,背景是这样的我先前去了农大龙子湖校园招聘投简历,然后第二天去面试了那经历可以说是很失败的一次面试,当然这跟自己的水平有关了接下来重点讲一下面试的题目: ...

  8. Servlet 中为多项选择题判分---String类的indexOf()方法妙用

    首先来看一下String类的indexOf()方法的用法: public class FirstDemo1 { /** *API中String的常用方法 */ // 查找指定字符串是否存在 publi ...

  9. Java字符串的匹配问题,String类的matches方法与Matcher类的matches方法的使用比较,Matcher类的matches()、find()和lookingAt()方法的使用比较

    参考网上相关blog,对Java字符串的匹配问题进行了简单的比较和总结,主要对String类的matches方法与Matcher类的matches方法进行了比较. 对Matcher类的matches( ...

随机推荐

  1. PHP的一些函数

    //进制转换类 base_convert //字符转十六进制 binhex

  2. IOS 表视图(UITableVIew)的使用方法(3)名单的索引显示

    当数据量特别大时,简单地以role进行分段,对实际查找的效率提升并不大.就像上一节开头所说,开发者可以根据球员名字的首字母进行分段,且分成26段.由于段数较多,可以使用UITableView的索引机制 ...

  3. android LayoutInflater的使用

    看其继承关系: public abstract class LayoutInflater extends Object java.lang.Object ↳ android.view.LayoutIn ...

  4. 电感耦合非接触IC卡系统的EMI问题

    射频识别(RFID)技术近年来发展迅速,并获得了广泛应用.但作为一种无线射频技术,其电磁兼容(EMC)性能也越来越受到人们的关注.RFID涉及的频率范围甚广,包括低于135kHz.13.56MHz.4 ...

  5. 文件的哈希值不在指定的目录文件中。此文件可能已损坏或被篡(Windows10 /Windows8.1)

    ------------------------------------------Windows10------------------------------------------------ ...

  6. 用C#开发较完整的Windows任务管理器

    原文 用C#开发较完整的Windows任务管理器 这个代码没有什么技术含量,仅仅使用 WMI 和 API 实现了 Windows 任务管理器的部分功能. 但代码里面封装了一个 SystemInfo 的 ...

  7. 面试题:在O(1)时间删除链表结点

    题目:给定单向链表的头指针和一个结点指针,定义一个函数在O(1)时间删除该结点. 链表结点与函数的定义如下: struct ListNode { int m_nValue; ListNode* m_p ...

  8. CI URL 辅助函数 url helper

    URL 辅助函数文件包含一些在处理 URL 中很有用的函数 加载辅助函数 本辅助函数通过如下代码加载: $this->load->helper('url'); 可用函数如下: site_u ...

  9. hdoj 2896 病毒侵袭(AC自动机)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2896 思路分析:题目为模式匹配问题,对于一个给定的字符串,判断能匹配多少个模式:该问题需要静态建树,另 ...

  10. Ext JS学习第十二天 Ext基础之操作dom ; get与fly 方法

    此文用来记录学习笔记 •嗯!首先,什么是DOM(Document Object Model) –W3C对DOM的定义:文档对象模型是一个平台,一个中立于语言的应用程序编程接口(API),允许程序访问并 ...