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基础知识(有代码有注释)

    回顾 数组: 数据的组合 数组定义: 三种方式(常用array()) 数组访问: 下标 数组分类: 关联数组, 索引数组和混合数组 数组循环遍历: foreach遍历(foreach原理) 二维数组: ...

  2. hdu 2815 Mod Tree 高次方程,n不为素数

    Accepted 406MS 8576K 2379 B C++/** 这里加了一点限制,,大体还是一样的,, **/ #include <iostream> #include <cs ...

  3. win使用telnet到ubuntu下vim显示中文为乱码的解决方法~

    1.几个路径: ubuntu: /etc/default/locale  相当于 centos:/etc/sysconfig/i18n vimrc的路径:① ~/.vimrc    ② /etc/vi ...

  4. C# Convert an enum to other type of enum

    Sometimes, if we want to do convert between two enums, firstly, we may think about one way: var myGe ...

  5. 从基因组可视化工具——circos说起,circos安装

      这是博客改版的第一篇博文,选择最近使用的生物信息学软件——circos开始写起.circos是用perl写的生物软件,从发表的文章来看 学习circos主要是熟悉配置文件的编辑方法,搞清楚其中的标 ...

  6. SumoLogic

    SumoLogic>>>Loggly. https://diyunpeng.loggly.com/setup MonitorWare http://www.monitorware.c ...

  7. Java面试题收集学习整理1

    1.java序列化.反序列化及serialVersionUID作用 ."=="和equals方法究竟有什么区别? .静态变量和实例变量的区别? 在语法定义上的区别:.Integer ...

  8. HDU 1870 愚人节的礼物

    题解:简单的数括号问题…… #include <cstdio> char s[1005]; int main(){ while(scanf("%s",s)!=EOF){ ...

  9. Silverlight CheckBoxList

    项目要用到复选框,可是在Silverlight中不存在CheckBoxList.通过查阅资料以及依据自己的理解,写了简单演示样例: 1.XAML <UserControl x:Class=&qu ...

  10. 【Java】【Fulme】Flume-NG源代码阅读之SpoolDirectorySource

    org.apache.flume.source.SpoolDirectorySource是flume的一个经常使用的source,这个源支持从磁盘中某目录获取文件数据.不同于其它异步源,这个源可以避免 ...