title: How to obtain the last path segment of a URI
body: <p>I have as input a string that is a <code>URI</code>. how is it possible to get the last path segment (that in my case is an id)?</p>
  <p>This is my input URL:</p>
  <pre><code>String uri = &quot;http://base_path/some_segment/id&quot;
  </code></pre>
  <p>and I have to obtain the id I have tried with this:</p>
  <pre><code>String strId = &quot;http://base_path/some_segment/id&quot;;
  strId = strId.replace(path);
  strId = strId.replaceAll(&quot;/&quot;, &quot;&quot;);
  Integer id =  new Integer(strId);
  return id.intValue();
  </code></pre>
  <p>but it doesn't work, and surely there must be a better way to do it.</p>