I have this file URL: `http://xxx.xxx.xx.xx/resources/upload/2014/09/02/new sample.pdf` which will be converted to `http://xxx.xxx.xx.xx/resources/upload/2014/09/02/new%20sample.pdf` later.

Now I can get the last path by:

```
public static String getLastPathFromUrl(String url) {
    return url.replaceFirst(".*/([^/?]+).*", "$1");
}

```

which will give me `new sample.pdf`

but how do I get the remaining of the URL: `http://xxx.xxx.xx.xx/resources/upload/2014/09/02/`
?