2012-09-23 58 views
0

为了得到HTTP直接链接到文件链接(与NAME延长) 像http://website.com/file.avi可以用JAVA:HTTP URL上获取文件名与文件ID

URL FileLocation = new URL("string"); 
String Name = FileLocation.getFile(); 

来完成这将与延长(/filename.ext)

但返回NAME如何到g等名对于网址用php ID喜欢

http:///website.com/download.php?d=9594 

我只想为此在JAVA。

+0

你想得到什么? '9594'? –

+0

检查[this](http://stackoverflow.com/questions/12250258/12252255#12252255)链接。 –

回答

0
File file=new File("C:/work/chandan/deepak.txt"); 
    URL url=null; 
.... 
.... 

url=file.toURL(); //file:/C:/work/chandan/deepak.txt 
System.out.println("The url is" + url);