Java method of intercepting strings
- 2020-04-01 03:53:01
- OfStack
This article illustrates a Java method for intercepting strings. Share with you for your reference. The specific implementation method is as follows:
public static void main(String args[]) {
//Begins interception with the first occurrence of this character
//String str="abc.def";
//String str="abc.def.sdfsdf.fsdfd.ddddd.ggggg.ttttt";
//String str1=str.substring(str.indexOf(".")+1, str.length());
//Begins interception with the last occurrence of the character
String str="http://wxj.videocc.net/wxj/images/2014/12/i3jwci4j.jpg";
String str1=str.substring(str.lastIndexOf("/")+1, str.length());
//Intercepts the next five characters
// String str="http://wxj.videocc.net/wxj/images/2014/12/i3jwci4j.jpg";
//String str1 = str.substring(str.length()-5,str.length());
System.out.println(str1);
}
I hope this article has been helpful to your Java programming.