If you are making a request to download a file and want to get the file name from a URL you could append the file without the extension with the file extension or use a utility to get the file name. The challenge with either approaches is that URLs contain parameters such as www.someurl.com?foo=bar that is unaccounted for. Alternatively you could write a regex to look for the . or build a URL. The first two snippets is in case you don't need to worry about parameters while the second set in case you do need to account for them while pulling the name from an web page address.