Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java中检查字符串是否以子字符串开头?_Java_String_Substring - Fatal编程技术网

如何在java中检查字符串是否以子字符串开头?

如何在java中检查字符串是否以子字符串开头?,java,string,substring,Java,String,Substring,我想检查是否以http://开头的字符串。没有循环我怎么做?提前感谢。在API中使用带有(字符串前缀)的公共布尔startsWith 例如:boolean isStartsWith=YOUR_STRING.startsWith(“http://”) 你基本上可以使用最简单的方法。。。i、 e字符串API提供的方法 public boolean startsWith(String prefix, int toffset) or public boolean sta

我想检查是否以http://开头的字符串。没有循环我怎么做?提前感谢。

在API中使用带有(字符串前缀)的
公共布尔startsWith

例如:
boolean isStartsWith=YOUR_STRING.startsWith(“http://”)


你基本上可以使用最简单的方法。。。i、 e字符串API提供的方法

public boolean startsWith(String prefix, int toffset)
                 or
public boolean startsWith(String prefix)
例如:

String str = new String("http://www.google.com");
str.startsWith("http://"); 

如果满足条件,则返回true,否则将返回false。

如果(str.indexOf(“http://”)==0)
?您的第一站应该始终是文档。
String str = new String("http://www.google.com");
str.startsWith("http://");