To get HTTP links with direct link to file (with NAME and EXTENSION)
like http://website.com/file.avi could be done with
URL FileLocation = new URL("string");
String Name = FileLocation.getFile();
which would return NAME with EXTENSION (/filename.ext)
but How to get Filename for URLs with php ID like
http:///website.com/download.php?d=9594
I want to do this in JAVA only.
You want to look for
Content-Dispositionfield in the header of HTTP response, e.g.Since it is in the HTTP header, you will need to start downloading the message first before getting the file name. Here is an example of how you use URLConnection and how to get a header field