indexOf substring

如下所示:

 1  public static void main(String[] args)
 2     {        
 3         String url = "http://bbs.zqh.com/user/login.html";
 4         System.out.println(url);
 5         int a = url.indexOf("/")+2;
 6         String surl1 = url.substring(a,url.length());
 7         System.out.println(surl1);
 8         int b = surl1.indexOf("/");
 9         String surl2 = surl1.substring(0,b);
10         System.out.println(surl2);
11         int c =surl2.indexOf(".");
12         String url3 = surl2.substring(c,b);
13         System.out.println(url3);
14     }
substring截取从0开始,截取的字符串理解为:str 大于等于起始,小于末尾。
下面是api的demo:
"hamburger".substring(4, 8) returns "urge"
 "smiles".substring(1, 5) returns "mile"
 
posted @ 2015-02-04 11:51  ZQH005  阅读(235)  评论(0编辑  收藏  举报