【发布时间】:2011-05-02 07:04:12
【问题描述】:
我输入了一个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不适用于Android 6.0 中的: