日期:2014-05-20  浏览次数:20659 次

怎么分割字符串
在数据库存入的字符串是http://v.youku.com/v_show/id_XNDA5OTU2NDMy.htmlhttp://www.tudou.com/playlist/p/a75485.html
怎么把提取出来的字符串分割成http://v.youku.com/v_show/id_XNDA5OTU2NDMy.html 

http://www.tudou.com/playlist/p/a75485.html这种形式



------解决方案--------------------
public class cutString
{
public static void main(String[] agrs)
{
String str="http://v.youku.com/v_show/id_XNDA5OTU2NDMy.htmlhttp://www.tudou.com/playlist/p/a75485.html";
int index=str.indexOf(".html");
String str1=str.substring(0,index+5);
String str2=str.substring(index+5);
System.out.println(str1);
System.out.println(str2);
}
}