You can use lastIndexOf()
method for same with
if (null != str && str.length() > 0 )
{
int endIndex = str.lastIndexOf("/");
if (endIndex != -1)
{
String newstr = str.substring(0, endIndex); // not forgot to put check if(endIndex != -1)
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…