我有一个输入字符串,其中包含一个URI
。如何获取最后一段路径(在我的情况下是一个id)?
这是我的输入网址:
String uri = "http://base_path/some_segment/id"
我需要获取id,我已经尝试过以下方法:
String strId = "http://base_path/some_segment/id";
strId = strId.replace(path);
strId = strId.replaceAll("/", "");
Integer id = new Integer(strId);
return id.intValue();
但是它不起作用,肯定会有更好的方法来实现它。
getLastPathSegment
在安卓6.0中无法处理带有:
的情况。 - Roman Soviak